prompt-toolkit / prompt-toolkit/python-prompt-toolkit
Multiple completions without nesting
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 10.6k
- Forks
- 815
- PR merge metrics
- No merged PRs in 30d
Description
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
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 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, but if I start with -s, the -I won't pop up afterwards. 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?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the NestedCompleter.from_nested_dict entry point and the surrounding completion behavior. The issue does not name files or tests; work would need to define how multiple independent options should be represented and what dynamic reloading should mean, then add coverage for the desired completion sequence.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100