Idea: Allow root options to be passed to subcommands
See original GitHub issueFor user convenience, it might make sense to allow passing global options as if they were sub-command options. For example, instead of requiring the user to write
command --root-option subcommand --sub-option
clikt could allow to write
command subcommand --root-option --sub-option
This would work unless there is an option name clash between the global command and the sub-command, in which case the sub-command-specific option should take precedence.
AFAIK there’s currently no elegant way to achieve this in clikt, so maybe it makes sense to implement this as a core feature toggle on the context, like subcommandsInheritGlobalOptions
or allowGlobalOptionsForSubcommands
.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:4
- Comments:17 (14 by maintainers)
Top Results From Across the Web
Clikt - Common Options With Subcommands
You can define your options on the root command and pass down the information via the context. With this design, you'll have to...
Read more >Shell - Zephyr Project Documentation
Root command (level 0): Gathered and alphabetically sorted in a dedicated memory section. Static subcommand (level > 0): Number and syntax must ...
Read more >CLI commands with google/subcommands - OSInet
We can perform this by adding instances of the commands to the subcommands.Register call besides commands , flags and help , in root.go...
Read more >Commands and Groups — Click Documentation (5.x)
Passing Parameters Click strictly separates parameters between commands and subcommands. What this means is that options and arguments for a specific command ...
Read more >picocli - a mighty tiny command line interface
This allows a specific option or positional parameter to use a different converter ... Format argument values can be passed to the printVersionHelp...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Feel free to look at our project for an example:
https://github.com/oss-review-toolkit/ort/blob/72db6534a875d82b425e4211bde1eeaedb775e8f/cli/build.gradle.kts#L32-L40
https://github.com/oss-review-toolkit/ort/blob/72db6534a875d82b425e4211bde1eeaedb775e8f/cli/src/main/kotlin/OrtMain.kt#L196-L203
Ok, I think I’ll hold off on implementing this for now. Thanks for taking the time to discuss!