{"id":2112,"library":"mando","title":"Mando: Create Python CLI apps","description":"mando is a lightweight Python library that wraps `argparse` to simplify the creation of command-line interface (CLI) applications. It allows developers to define CLI commands using Python functions and decorators, automatically generating argument parsers from function signatures and docstrings. Key features include support for Python 3-style type annotations for argument conversion, and compatibility with various docstring formats (Sphinx, Google, NumPy). It also supports shell autocompletion through the optional `argcomplete` package. The current version, 0.8.2, was released on October 20, 2024, and focuses on Python 3 compatibility.","status":"active","version":"0.8.2","language":"en","source_language":"en","source_url":"https://github.com/rubik/mando","tags":["CLI","argument parsing","argparse","command-line","developer-tools"],"install":[{"cmd":"pip install mando","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Optional, for shell autocompletion functionality.","package":"argcomplete","optional":true}],"imports":[{"symbol":"command","correct":"from mando import command"},{"symbol":"main","correct":"from mando import main"}],"quickstart":{"code":"from mando import command, main\n\n@command\ndef echo(text, capitalize=False):\n    '''Echo the given text.\n    :param text: The text to echo.\n    :param capitalize: Whether to capitalize the text.\n    '''\n    if capitalize:\n        text = text.upper()\n    print(text)\n\nif __name__ == '__main__':\n    main()","lang":"python","description":"This quickstart demonstrates how to define a command-line function using the `@command` decorator and make it executable with `main()`. It handles arguments and optional flags, showcasing how `mando` parses them from function signatures and docstrings. To run, save as `my_cli.py` and execute `python my_cli.py echo \"hello world\" --capitalize` or `python my_cli.py echo \"hello world\"`."},"warnings":[{"fix":"Upgrade to Python 3 and install `mando>=0.8.0` or pin `mando<0.8.0` for Python 2 projects (though this is not recommended).","message":"Mando versions 0.8.x and above have dropped support for Python 2. Users on older Python 2 environments should use an earlier `mando` version or migrate to Python 3.","severity":"breaking","affected_versions":"<0.8.0"},{"fix":"Consult `mando` documentation on 'Other Docstring Formats' for configuration options if using non-Sphinx styles.","message":"Mando automatically infers command arguments from function signatures and docstrings. By default, it expects Sphinx-style docstrings. If your project uses Google or NumPy style docstrings, you may need to explicitly configure this for optimal parsing.","severity":"gotcha","affected_versions":"All"},{"fix":"Decorate your command function parameters with `@arg('param_name', ...)` before the `@command` decorator to customize individual arguments.","message":"For fine-grained control over argument parsing (e.g., specifying `metavar`, `choices`, or overriding inferred types), use the `@arg` decorator. This decorator allows passing arguments directly to `argparse.add_argument()` and will override information inferred from the function signature or docstring.","severity":"gotcha","affected_versions":"All"},{"fix":"Always prefer installing `mando` via `pip install mando` to ensure you receive the latest stable version and its full feature set, especially for Python 3 development.","message":"Some system package managers (e.g., for certain Linux distributions) may offer older versions of `mando` (e.g., 0.6.4, 0.7.1) that are not up-to-date with the latest features or Python 3 compatibility.","severity":"deprecated","affected_versions":"<0.8.0"}],"env_vars":null,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}