docopt-ng is a Jazzband-maintained fork of the original docopt library, providing a humane command-line arguments parser for Python 3.7+. It generates command-line interfaces by parsing a script's docstring, which defines usage patterns and option descriptions. The library aims to offer maintenance, type hints, and complete test coverage. While actively maintained, its release cadence can be irregular, with the latest major release (0.9.0) occurring almost a year ago as of verification.
pip install docopt-ngVerified import paths — ran on the pinned version, not inferred.
Define your command-line interface directly in a docstring, then pass it to the `docopt` function. The function returns a dictionary of parsed arguments. This example demonstrates a simulated command-line input for a 'Naval Fate' application, parsing commands, arguments, and options.
Review your docstring definitions against the strict `docopt` specification, especially regarding implicit behaviors or non-standard syntax that may have been previously tolerated. Ensure adherence to `docopt`'s explicit usage patterns and option descriptions.
Ensure that only `docopt-ng` is installed in your environment, or explicitly manage your `PYTHONPATH` to prioritize `docopt-ng` if both must coexist. Preferably, use separate virtual environments.
Always explicitly define options with arguments using either `--option=<arg>` or `-o <arg>` consistently, and always provide clear option descriptions. Refer to the `docopt` documentation for precise syntax rules for usage patterns and option descriptions.
For versions 0.8.0 and later, `from docopt import DocoptExit` is the correct and reliable way to import the exception. For older versions, direct import might not work and a workaround might be needed, or consider upgrading.
Install `docopt-ng` using pip: `python -m pip install docopt-ng`. Ensure you are running your script with the Python interpreter where the package was installed, especially if you have multiple Python versions.
Ensure your script's docstring (or the string passed to `docopt`) includes a 'Usage:' line followed by your command-line interface patterns. For example: `"""My Program. Usage: my_program [options]"""`.
Carefully review your docstring's 'Usage:' patterns and 'Options:' descriptions. Ensure all elements are clearly and consistently defined according to `docopt`'s grammar. Pay close attention to how arguments are specified (e.g., `--option ARG` vs `--option=ARG`) and that options are properly listed in the descriptions.
Preferably, use separate virtual environments to prevent conflicts. If both cannot be avoided, explicitly manage your `PYTHONPATH` to prioritize `docopt-ng`, or ensure only `docopt-ng` is installed: `pip uninstall docopt` then `pip install docopt-ng`.
No dependency data recorded yet.