Perform autocomplete for the given input arguments. If not completing a top level command (or "help"), this function passes the arguments down to the appropriate plugins for per-plugin autocompletion.
(cmds, plugins, config, argv)
| 51 | |
| 52 | |
| 53 | def autocomplete(cmds, plugins, config, argv): |
| 54 | """ |
| 55 | Perform autocomplete for the given input arguments. If not |
| 56 | completing a top level command (or "help"), this function passes |
| 57 | the arguments down to the appropriate plugins for per-plugin |
| 58 | autocompletion. |
| 59 | """ |
| 60 | |
| 61 | option = "default" |
| 62 | current_word = argv[0] |
| 63 | argv = argv[1:] |
| 64 | |
| 65 | if argv and argv[0] == "help": |
| 66 | argv = argv[1:] |
| 67 | |
| 68 | comp_words = list(cmds.keys()) + ["help"] |
| 69 | comp_words = cli.util.completions(comp_words, current_word, argv) |
| 70 | if comp_words is not None: |
| 71 | return (option, comp_words) |
| 72 | |
| 73 | plugin = cli.util.get_module(plugins, argv[0]) |
| 74 | plugin_class = getattr(plugin, plugin.PLUGIN_CLASS) |
| 75 | |
| 76 | return plugin_class(settings, config).__autocomplete_base__( |
| 77 | current_word, |
| 78 | argv[1:]) |
| 79 | |
| 80 | |
| 81 | def main(argv): |
no test coverage detected