Skip to content

Add argument groups #40

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

Closed
seaneagan opened this issue Jan 13, 2014 · 0 comments
Closed

Add argument groups #40

seaneagan opened this issue Jan 13, 2014 · 0 comments

Comments

@seaneagan
Copy link
Owner

Grouping arguments would allow for over-arching documentation for specific groups of arguments.

Might be able to use a similar interface as #33 for this. Possibly only annotate first arg of group, and assume all args until next group annotation are in that group:

script({
  int timeout,
  // ... other options that don't belong to a specific group.
  @HelpBlock('Formatting options', 'Options to tailor the output')
  bool indent,
  String separator: ' ',
  //...
}) {

}

Positional arguments should just be in their own single group, since there should never be more than 2 or 3 of them.

Possibly related dart feature request, which might be able to provide a less command-line specific interface for this: http://dartbug.com/2783

Also, flag groups could be made mutually exclusive where only one option from the group can be specified, otherwise a helpful error message is displayed. For example, there might be multiple verbosity options like --quiet, --verbose, --trace etc, see #4. These options could potentially be modeled by an enum (when dart supports those), and a single enum value could be passed to the script method,

class Verbosity {

  final Level;

  const Verbosity._(this.level);

  static const Verbosity 
      QUIET = const Verbosity._(Level.OFF),
      VERBOSE = const Verbosity._(Level.FINE),
       YELL = const Verbosity._(Level.ALL);

  static const values =  const [QUIET, VERBOSE, OFF];
}

Still need to think about the interface to declare that a script takes one of these mutually exclusive flag groups. It might involve the allowed attribute, and be related to #13.

Note: Verbosity option groups may not actually be passed as a direct value, see #4.

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

No branches or pull requests

1 participant