I am writing a shell-like command REPL, the format of command is similar to shell. But it has nothing with shell. The program take input and use shlex to split and feed it to a collections of objects whose type is subclass of click.BaseCommand.
What I hope is to make prompt_toolkit.prompt("$>>") provide autocomplete depend on the content in command_dict without any redundant definition, in other words, when the content in command_dict changed (for example add new command, or the Command object in command_dict become Group object, and add new sub-commands), the auto-complete content will automatically change accordingly.
I am writing a shell-like command REPL, the format of command is similar to shell. But it has nothing with shell. The program take input and use
shlex
to split and feed it to a collections of objects whose type is subclass ofclick.BaseCommand
.Something like that:
What I hope is to make
prompt_toolkit.prompt("$>>")
provide autocomplete depend on the content in command_dict without any redundant definition, in other words, when the content incommand_dict
changed (for example add new command, or theCommand
object incommand_dict
becomeGroup
object, and add new sub-commands), the auto-complete content will automatically change accordingly.Is it possible?
What is the best practice to achieve that?