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

Provide option metadata #3

Closed
con-f-use opened this issue Aug 6, 2019 · 2 comments
Closed

Provide option metadata #3

con-f-use opened this issue Aug 6, 2019 · 2 comments

Comments

@con-f-use
Copy link

con-f-use commented Aug 6, 2019

For the following option definition

-c --count=<int>    Option for a count of some kind [default: 42] 

Is there a way to retrieve the default value ( 42) and the value of the value designation (<int>) programatically? I.e. is the a way to get from the resulting args after docopt-ng is done parsing? I have an oustanding PR in original docopt for that sort of change but, as well all know, that's not going to be merged.

@con-f-use
Copy link
Author

To answer my own question: The PR I just made will take care of the <int> thing, while the 42 thing (and, once the PR is merged, the argument type, i.e. <int>) can be accessed via the parse_defaults function:

from docopt import docopt, parse_defaults
args = docopt(__doc__)
atypes = {(o.longer or o.short):o.atype, o.value for o in parse_defaults(__doc__)}
defaults = {(o.longer or o.short):o.value, o.value for o in parse_defaults(__doc__)}

@NickCrews
Copy link
Contributor

I'm going to close this as not going to implement, see #4 for discussion.

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

2 participants