Skip to content

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

Description

@Lord-Kamina

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions