click-contrib / click-repl

Subcommand REPL for click apps
MIT License
215 stars 41 forks source link

Hide already used (non-`multiple`) options #104

Closed ZanyMonk closed 12 months ago

ZanyMonk commented 1 year ago

Change only applied for options with multiple=False.

Before

> cmd <TAB>
                      --foo
                      --bar
> cmd --foo t <TAB>
                      --foo
                      --bar

After

> cmd <TAB>
                      --foo
                      --bar
> cmd --foo t <TAB>
                      --bar
GhostOps77 commented 1 year ago

This is made just to replicate the behaviour of the click's parsing style if you've already supplied the values for the foo like -foo t, and if u supply it again like -foo R then, foo's value will be overwritten as R from t

This is actually the intended way of behaviour

ZanyMonk commented 1 year ago

@auvipy please check your CI.

@GhostOps77 this PR does not disallow one to use an option multiple times, it just hides the ones already used from the completions, which makes it much more practical in my opinion (you don't have to sort through all the options you already added to the command).

I can make it optional if you prefer. If not, just remove the PR :)

GhostOps77 commented 1 year ago

@ZanyMonk It's a linter error, format the code before committing also, it would be better to have it as a flag to the completer class (via prompt kwargs) to decide whether to show already used non-multiple options or not

ZanyMonk commented 1 year ago

Made it optional and fixed the format to fit flake8 test.