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

Parameter post-converters #24

Open
epsy opened this issue Apr 28, 2017 · 0 comments
Open

Parameter post-converters #24

epsy opened this issue Apr 28, 2017 · 0 comments
Assignees
Milestone

Comments

@epsy
Copy link
Owner

epsy commented Apr 28, 2017

Currently Clize converts each Python parameter to a Parameter instance by calling a function and using its result:

  • Either the first annotation on that parameter if it is a parameter converter,
  • or the default converter

This makes it impossible to use parameters.multi with parameters.one_of, for instance. This is counter-intuitive and also quite unfortunate.

To fix this, the parameter converter should collect callables from the annotations designated as "post-converters". Once the parameter converter has completed creating a Parameter instance, it should post-process this parameter with each post-converter in order. Each post converters does some changes and returns a Parameter instance, much like decorators.

Example post-converters:

  • parameter.one_of, parameter.mapped, (both already existing as parameter converters)
  • argument_decorator, (already existing as parameter converter)
  • Something to change the name of the value in the help (argparse calls it metavar)
  • UNDOCUMENTED and LAST_OPTION could be refactored as post-converters.

The documentation will need additional clarification on the roles of parameter converters, post-converters and value converters, possibly with a drawing :)

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