Skip to content

Automatic "allowed" when parameter is an enum #13

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

Open
seaneagan opened this issue Dec 18, 2013 · 2 comments
Open

Automatic "allowed" when parameter is an enum #13

seaneagan opened this issue Dec 18, 2013 · 2 comments

Comments

@seaneagan
Copy link
Owner

When dart supports enums, it should be possible to annotate a parameter as an enum, and have the "allowed" configuration automatically set. May need to provide configuration of how the enum constant names are mapped to strings. The help text could come from the doc comments of the enum constants, as in #11

@seaneagan
Copy link
Owner Author

@seaneagan
Copy link
Owner Author

Since it's still not possible to access doc-comments using mirrors, it could be:

main(args) => new Script(peel).execute(args);

@Command(help: 'Peel a fruit')
peel(Fruit fruit) {
  print('Peeling the ${fruit.name}')
}

enum Fruit {
  @Help('Tart.') apple,
  @Help('Citrusy.') orange,
  @Help('Aromatic.') banana
}
peel -h

peel <fruit>

<fruit>
  [apple]     Tart.
  [orange]    Citusy.
  [banana]    Aromatic.

For enum.name, see http://dartbug.com/21712.

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

No branches or pull requests

1 participant