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

ability to declare long parameters using just a single -, e.g. -Ssendwait #69

Open
FelixSchwarz opened this issue Aug 8, 2024 · 2 comments

Comments

@FelixSchwarz
Copy link

Some Unix commands have longer parameter names which just start with a single dash, e.g. -Ssendwait. argparse can handle these parameters but I'm unable to do this with docopt-ng:

#!/usr/bin/env python3
"""
Usage:
  foo [options]

Options:
  -Ssendwait     wait until request was sent
  -Snosendwait   return immediately
"""

from docopt import docopt
arguments = docopt(__doc__)
print(arguments)
$ ./parse-docopt.py -Snosendwait
Warning: found unmatched (duplicate?) arguments [Option('-S', None, 0, True), Option('-n', None, 0, True), Option('-o', None, 0, True), Option('-s', None, 0, True), Option('-e', None, 0, True), Option('-n', None, 0, True), Option('-d', None, 0, True), Option('-w', None, 0, True), Option('-a', None, 0, True), Option('-i', None, 0, True), Option('-t', None, 0, True)]
Usage:
  foo [options]
@NickCrews
Copy link
Contributor

NickCrews commented Dec 3, 2024

Hi! Thanks for the issue. Can you explain why you need to use this new syntax, and the existing syntax isn't adequate? Compatibility with an existing other command? Which one? Eg what is stopping you for defining your API as '--nosendwait'? I'm hesitant to increase the scope of docopt unless there is no other workaround. (I realize I'm being curmudgeonly here, thanks for your patience). Thank you!

@FelixSchwarz
Copy link
Author

Yes, this is 100% just to reproduce the CLI parameters of existing applications like /usr/bin/mailx and /usr/bin/sendmail. I can understand if this is out of scope for docopt and it is certainly not a "common" thing. Currently I am resorting to argparse here but I'd love to use only docopt, maybe even by handing in some custom CLI parser or so?

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