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

Group and label option groups in the help screen #267

Closed
natecook1000 opened this issue Feb 8, 2021 · 1 comment · Fixed by #492
Closed

Group and label option groups in the help screen #267

natecook1000 opened this issue Feb 8, 2021 · 1 comment · Fixed by #492
Labels
enhancement New feature or request

Comments

@natecook1000
Copy link
Member

Option groups are currently just splatted into the rest of the declared arguments for a command. This is sometimes fine, but often it would be nice if option groups were separated and labeled, which would (a) help readability in complex commands and (b) help users understand which options carry over across multiple subcommands.

For example, for declarations like this:

struct Options: ParsableArguments {
    @Flag(help: "Display extra information while processing.")
    var verbose = false

    @Option(help: "The number of extra lines to show.")
    var extraLines = 0
}

struct Example: ParsableCommand {
    @OptionGroup(title: "Shared Options")
    var group: Options

    @Flag(help: "Parse as a binary file.")
    var parseAsBinary = false

    @Argument(help: "The input file.")
    var inputFile: String?
}

The help screen could look something like:


% example --help
USAGE: example [--verbose] [--extra-lines <extra-lines>] [--parse-as-binary] <input-file>

ARGUMENTS:
  <input-file>            The input file.

OPTIONS:
  --parse-as-binary       Parse as a binary file.

SHARED OPTIONS:
  --verbose               Display extra information while processing.
  --extra-lines <extra-lines>
                          The number of extra lines to show. (default: 0)

  -h, --help              Show help information.
@natecook1000
Copy link
Member Author

It would probably also be helpful to be able to hide an entire option group from the help for a command.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant