Allow to strip dashes from options in result dictionary
See original GitHub issueFrom the project README:
The return value is a simple dictionary with options, arguments and commands as keys, spelled exactly like in your help message.
options['--file']
looks too odd though. That would be great if a user could invoke docopt with additional named parameter:
options = docopt(__doc__, strip_dashes=True)
So that result dictionary has no leading dashes, which is equivalent to:
def strip_dashes(options):
return {k.lstrip('-'): v for k, v in options.items()}
options = strip_dashes(docopt(__doc__))
Will you accept pull request for this feature?
Issue Analytics
- State:
- Created 9 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Removing dashes from strings in Python - Stack Overflow
I'm trying to write code that will remove dashes from a string if it's in the middle of a word and not between...
Read more >Format hyphens, dashes, and quotation marks in Pages on Mac
Turn smart dashes on or off · Choose Pages > Settings (from the Pages menu at the top of your screen). · Click...
Read more >python - How do I remove hyphen from field column
Use the built-in str.replace method accessible on all string objects. Make sure Python is checked in the Parser at the top.
Read more >Settings - Pleco for Android
Enable Cantonese - Display Cantonese text in entries from dictionaries that include Cantonese pronunciations; if any one of the dictionaries with a definition ......
Read more >dash(1) - Linux manual page - man7.org
This option has no effect when set after the shell has already started running (i.e. with set). -V vi Enable the built-in vi(1)...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Had the same issue. I’m using this one liner:
args = {arg.lstrip('-') : value for arg, value in docopt(__doc__).items()}
Coming back to post it here, I realised @pavel-paulau has basically the same thing in his original post.
@dmwelch let me know if docopt-dispatch solves your problem. If it gets popular I will integrate it into docopt.