Skip to content

Am I required to pass regular arguments before my subcommand? #5375

Answered by epage
weezy20 asked this question in Q&A
Discussion options

You must be logged in to vote

Once we start parsing a subcommand, we cannot parse arguments from a parent command. There is a caveat to this that I'll get to.

Is addr truly universal between your subcommands or is this purely for coding convenience? From a CLI design perspective, I generally recommend that the focus be on arguments to your subcommands. The reason to have arguments on your parent command are if they are mutually exclusive with commands (e.g. cargo --list) or if they are orthogonal to subcommands (e.g. cargo --verbose) but even those can be suspect as it is generally expected to run cargo check -v rather than cargo -v check. It is also easy to think that an argument is universal to all commands until a …

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@weezy20
Comment options

@epage
Comment options

@weezy20
Comment options

Answer selected by weezy20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants