2

I am curious if there is a way to do multiple completions without having a ton of nested dicts.

If I look at the example they have

completer = NestedCompleter.from_nested_dict(
    {
        "show": {
            "-i": {
                "a": None,
                "b": None,
                "c": None,
                "clock": None,
            },
            "-s": {"interface": {"brief": None}, "other": None},
        },
        "exit": None,
    }
)

And run this, I can autocomplete either for -I or -s.

If I add edit the dictionary for -a a to know -s comes, namely something like:

completer = NestedCompleter.from_nested_dict(
    {
        "show": {
            "-i": {
                "a":{"-s":{"interface":None},
                "b": None,
                "c": None,
                "clock": None,
            },
            "-s": {"interface": {"brief": None}, "other": None},
        },
        "exit": None,
    }
)

Then if I type -I a, it will autocomplete the -s for me. This is fine if I have 2 options with a couple choices, but when I get up to multiple options with multiple choices, this could get slow and have to be a large dict going through all possible input combinations.

Is there a way to get around this and reload the completer once a single option is chosen?

yankeefan11
  • 485
  • 1
  • 6
  • 18

0 Answers0