Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow making inherited options hidden on subcommands #983

Closed
remkop opened this issue Apr 6, 2020 · 2 comments
Closed

Allow making inherited options hidden on subcommands #983

remkop opened this issue Apr 6, 2020 · 2 comments
Labels
theme: usagehelp An issue or change related to the usage help message type: API 🔌 type: enhancement ✨
Milestone

Comments

@remkop
Copy link
Owner

remkop commented Apr 6, 2020

This depends on #649.

Once inherited/global options are implemented, there will be cases where the top-level command defines many shared options, and each subcommands defines only the options applicable for that specific command. Applications may want to define some or all of the top-level options as "global" or "inherited" options, so they can be specified on the top-level command as well as on the subcommand.

However, they may not want the inherited options to clutter the usage help message of the subcommand, especially if there are many inherited options.

Ideas for Programmatic Solution

Provide API to allow subcommands to hide inherited options. For example:

CommandLine::setHideInheritedOptions(boolean) // on the full hierarchy
CommandSpec::hideInheritedOptions(boolean) // on a specific command

Ideas for Declarative Solution

Add an enumeration value to hide inherited options. For example:

public enum ScopeType {
    /** The element only exists in the current command. */
    LOCAL,
    /** The element exists in the command where the element is defined
     * and all descendents (subcommands, sub-subcommands, etc.). */
    INHERIT,
    /** The element exists in the command where the element is defined
     * and all descendents (subcommands, sub-subcommands, etc.),
     * but is not shown in the usage help for the descendents. */
    INHERIT_AS_HIDDEN,
}

TBD should this apply to inherited positional parameters?

@remkop remkop added this to the 4.3 milestone Apr 6, 2020
@remkop remkop added the theme: usagehelp An issue or change related to the usage help message label Apr 14, 2020
@remkop remkop modified the milestones: 4.3, 4.4 May 6, 2020
@remkop
Copy link
Owner Author

remkop commented Jun 2, 2020

Some work is in progress to address this: the tickets below make it easier to customize the option list in the usage help message. However, it is not yet possible to customize the synopsis...

@remkop
Copy link
Owner Author

remkop commented Jun 6, 2020

This is now implemented in master.

See these examples for how to accomplish this:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
theme: usagehelp An issue or change related to the usage help message type: API 🔌 type: enhancement ✨
Projects
None yet
Development

No branches or pull requests

1 participant