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

Failing to put two spaces in description sometimes results in very obscure error. #44

Open
Lord-Kamina opened this issue Nov 15, 2022 · 1 comment

Comments

@Lord-Kamina
Copy link

Lord-Kamina commented Nov 15, 2022

I just began using docopt-ng. I was creating my interface from scratch (I currently use a functional but spaghetti-like script), and my docstring read something like:

"""Performous macOS Bundler

Usage:
    macos_bundler.py
    macos_bundler.py [options]
    macos_bundler.py (-h | --help)

Options:
...
"""

But I kept getting the following error and couldn't figure out why.

    raise tokens.error("unmatched '%s'" % token)
docopt.DocoptLanguageError: unmatched '('

I double checked brackets and there were definitely no unmatched ones. I then double-checked the documentation to make sure I hadn't made a mistake with the syntax, and I couldn't find one.

I had read sometimes docopt (I think the original one?) had issues with pipes, so even though that exact syntax appeared in the documentation, I tried to remove the macos_bundler.py (-h | --help) line and, the error went away; but I couldn't use either -h nor --help, because it kept telling me those optons needed an argument.

Upon closer inspection, I noticed I had missed a space between -h --help and the option description.

So, it seems missing writing something such as

"""Command
Usage:
    cli_tool.py (-s | --long)

Options:
    -s --long Some description for this option.
"""

Will produce such an error.

Of course, there is an error there, and one the documentation specifically warns against. However, in this particular scenario, the error message was very obscure.

@NickCrews
Copy link
Contributor

Thanks for the issue, I agree. I'd be very happy to accept a PR that fixes this, but I'm not motivated enough to dig into the legacy hand-rolled parser to tackle this at the moment myself.

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