urfave / cli

A simple, fast, and fun package for building command line apps in Go
https://cli.urfave.org
MIT License
21.89k stars 1.69k forks source link

Stop command aliases and flag aliases from being suggested in shell completion #1882

Closed bartekpacia closed 2 months ago

bartekpacia commented 2 months ago

What type of PR is this?

Which issue(s) this PR fixes:

This PR fixes #1875. It is the second try, now targeting v3. The first try, targeting v2, was in #1876.

Release Notes

- Command aliases and flag aliases are no longer included in shell completions (#1882)
dearchap commented 2 months ago

@Juneezee didnt we say we want a runtime config flag to enable this behavior ?

bartekpacia commented 2 months ago

Hi @dearchap. From my perspective as an avid user of the terminal and fan of CLI tools, I think shortcuts of commands being hidden during shell completion is more common (and personally, I prefer it this way also). Especially that this is targeting v3 so some small minor changes are OK. I am all for adding a flag to control this behavior.

Of course, you are the maintainer and the one to make the call.

We could also add an environmental variable that all CLI tools built with urfave/cli would respect. Perhaps SHELL_COMPLETION_SHOW_ALIASES? Think of it as something similar to the NO_COLOR env var, which is very widely respected.

So, if SHELL_COMPLETION_SHOW_ALIASES was to 1 or true, aliases of commands/flags would be shown. Maybe we could also get other popular CLI packages (such as e.g. Cobra) to adopt it? I'd be happy to know what you (maintainers) think about it :)

dearchap commented 2 months ago

Yeah that makes sense

meatballhat commented 2 months ago

@dearchap Did you want to see the introduction of the SHELL_COMPLETION_SHOW_ALIASES environment variable switch that @bartekpacia described within this PR, or is merging now and adding in a follow-up acceptable?

dearchap commented 2 months ago

Merging now is acceptable