-
Notifications
You must be signed in to change notification settings - Fork 123
Subcommand parsing logic stops at first flag #90
Comments
Without having a deeper understanding of the flag package in use (since this library has no opinion on it, it just passes However, this cli library DOES handle So, if this issue is talking about flags generally, I don’t think this behavior can be changed. But if we’re talking about the help flag specifically there is something here I think. Please let me know if I’m misunderstanding. |
Hey @mitchellh , the issue is focusing on flags generally, not specificallly The behavior I am proposing would be to identify |
FWIW over in Terraform we are intentionally making a distinction between options that appear before the command (global options) and options that appear after the command (command-specific options) and so I think I agree with @mitchellh that making this library itself try to recognize options prior to the command could have adverse affects on existing callers making different assumptions. In the case of Terraform, we achieve this in a kinda-awkward way of pre-analyzing the original args, noticing the index of the first non-flag argument, and then splitting the args slice into a "global flags" portion and an "everything else" portion. We then pass the global flags portion to the Go |
Noticed this behavior on an internal tool, essentially, if you have flags defined for a command, then execute a subcommand of that command with a flag before the subcommand, then it identifies the command as the
subcommand
.For example, if we take the test cases @ https://github.com/mitchellh/cli/blob/master/cli_test.go#L1459-L1489 and change it to:
I guess the question is, with other tools like
cobra
which handle flags anywhere within the arguments, does it make sense to change this library's behavior?The text was updated successfully, but these errors were encountered: