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

Unify @Option and @Parameters annotations #63

Closed
remkop opened this issue Mar 5, 2017 · 1 comment
Closed

Unify @Option and @Parameters annotations #63

remkop opened this issue Mar 5, 2017 · 1 comment
Labels
status: declined ❌ A suggestion or change that we don't feel we should currently apply type: enhancement ✨

Comments

@remkop
Copy link
Owner

remkop commented Mar 5, 2017

Options on how to do this:

  • Combine into single annotation "Parameter"
  • Shared super-interface ("Parameter"), Option and PositionalParameter
+----------+         +---------------+        +---------------------+
| Option   | ----->  |  Parameters   | <----- | PositionalParameter |
+----------+         +---------------+        +---------------------+
| names    |         | description   |        | position            |
| required |         | arity         |        +---------------------+
| help     |         | paramLabel    |         
+----------+         | type/converter|         
                     | hidden        |         
                     +---------------+         
@remkop remkop added this to the 0.3.0 usage online help milestone Mar 5, 2017
@remkop remkop added the status: declined ❌ A suggestion or change that we don't feel we should currently apply label Mar 17, 2017
@remkop
Copy link
Owner Author

remkop commented Mar 17, 2017

Annotations don't support inheritance.

I considered following JCommander's design of having a single annotation to denote both options and positional parameters, but I'm not convinced it's a good idea. (There's an experimental branch where this idea is implemented.) Having a single annotation seems to simplify things but it turns out that it just moves the complexity. Options are different from positional parameters: they have one or more names and may take a parameter. Positional parameters have an index. Trying to model this in a single annotation means a lot of conditional logic in picoCLI, and for users it can be confusing: should I provide both a name and an index? What if I specify neither?

Separate annotations seems cleaner. For example, it allows us to make the @option names attribute mandatory, enforced by the compiler, which is very nice. I think the explicit separation makes the concepts easier to grasp for users, so this is a better design.

@remkop remkop closed this as completed Mar 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: declined ❌ A suggestion or change that we don't feel we should currently apply type: enhancement ✨
Projects
None yet
Development

No branches or pull requests

1 participant