posener/complete

Flags are over-recommended

disq opened this issue · 1 comments

disq commented

Global flags should not be valid/recommended after a subcommand, should they? Currently in s5cmd/develop I'm reading COMP_LINE and checking if any subcommands (well, "non-flags") are specified, if they are, I reset Command.Flags to nil (before the complete.New() call) to remedy this. Also, some flags can be mutually exclusive. So, a way to turn off a specific flag might be handy and help with these cases. Flags are also recommended after arguments, which doesn't seem like a common/intuitive use to me.

To help with these issues, maybe support a flag "callback" to dynamically disable a particular flag? Where one might check for Args.Last and if there's an argument (non-flag) there (or a mutually-exclusive option is already specified) disable the flag essentially making the completion smarter. (I might make a PR for this if you like, if you don't have something better in mind that is...)

Thanks @disq good catch,
I'm currently thinking of splitting the Flags to command flags and global flags, by which command can only be between command and sub-command, but global can appear anywhere.