You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to achieve the following CLI, with default arguments (output, profile, ...) shared by all subcommands.
mycli subcmd1 --output=json --profile=a
mycli subcmd2 --output=json --profile=a
mycli mygroup subcmd3 --output=json --profile=a
What do you think the best way is to do that?
There are scores of subcommands, so adding that per command is not ideal.
I also want to make sure the option is also hidden from each command's help command, because this is a convention of the master CLI, so it should not pollute the help of each subcommand. There are multiple other similar options like that, too.
Also, there are multiple such common arguments, e.g. --output, --debug. I don't want to have each subcommand function signature include them, which is too verbose and makes them not shared.
One approach in the Click lib, is to associate common arguments to the master CLI or a group. However, that has a limitation that I must use the CLI like below, which is not ideal.
mycli --output json --profile a subcmd1
mycli --output json --profile a subcmd2
A real world example, is the CLI command like kubectl, you can specify common parameter like "-o" anywhere in the CLI.
I think this is a common requirement for modern CLI. However no luck finding how Click could support that so far. Advice is appreciated.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I want to achieve the following CLI, with default arguments (output, profile, ...) shared by all subcommands.
What do you think the best way is to do that?
There are scores of subcommands, so adding that per command is not ideal.
One approach in the Click lib, is to associate common arguments to the master CLI or a group. However, that has a limitation that I must use the CLI like below, which is not ideal.
A real world example, is the CLI command like kubectl, you can specify common parameter like "-o" anywhere in the CLI.
I think this is a common requirement for modern CLI. However no luck finding how Click could support that so far. Advice is appreciated.
Beta Was this translation helpful? Give feedback.
All reactions