Skip to main content

CLI Command Parser

Project description

downloads py_version coverage_badge build_status Ruff OpenSSF Best Practices

CLI Command Parser is a class-based CLI argument parser that defines parameters with descriptors. It provides the tools to quickly and easily get started with basic CLIs, and it scales well to support even very large and complex CLIs while remaining readable and easy to maintain.

Some of the primary goals and key features of this project:
  • Minimal boilerplate code is necessary to define CLI parameters and access their parsed values

  • Typing support for CLI parameters that can be validated via type checkers

  • Subcommands can inherit common parameters so they don’t need to be repeated

  • Easy to handle common initialization tasks for all actions / subcommands once

Example Program

from cli_command_parser import Command, Option, main

class Hello(Command):
    """Simple greeting example"""

    name = Option('-n', default='World', help='The person to say hello to')
    count = Option('-c', type=int, default=1, help='Number of times to repeat the message')

    def main(self):
        for _ in range(self.count):
            print(f'Hello {self.name}!')

if __name__ == '__main__':
    main()
$ hello_world.py --name Bob -c 3
Hello Bob!
Hello Bob!
Hello Bob!

$ hello_world.py -h
usage: hello_world.py [--name NAME] [--count COUNT] [--help]

Simple greeting example

Optional arguments:
  --name NAME, -n NAME        The person to say hello to (default: 'World')
  --count COUNT, -c COUNT     Number of times to repeat the message (default: 1)
  --help, -h                  Show this help message and exit

Installing CLI Command Parser

CLI Command Parser can be installed and updated via pip:

$ pip install -U cli-command-parser

There are no required dependencies. Support for formatting wide characters correctly in help text descriptions can be included by adding wcwidth to your project’s requirements, and/or by installing with optional dependencies:

$ pip install -U cli-command-parser[wcwidth]

Python Version Compatibility

Python versions 3.10 and above are currently supported. The last release of CLI Command Parser that supported 3.9 was 2025-09-27. Support for Python 3.9 officially ended on 2025-10-31.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cli_command_parser-2026.6.27.tar.gz (144.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cli_command_parser-2026.6.27-py3-none-any.whl (172.0 kB view details)

Uploaded Python 3

File details

Details for the file cli_command_parser-2026.6.27.tar.gz.

File metadata

  • Download URL: cli_command_parser-2026.6.27.tar.gz
  • Upload date:
  • Size: 144.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for cli_command_parser-2026.6.27.tar.gz
Algorithm Hash digest
SHA256 fb74ecbf6d82352c510e03d1e265e752c8e47720318934366e2d2aabdf4d67d9
MD5 3c74a3fe7b007c1366559fd5a6b0399a
BLAKE2b-256 f6c0230691de4810187d6195bd2f4c615b6de32211ebb46abfaf9f635906916e

See more details on using hashes here.

File details

Details for the file cli_command_parser-2026.6.27-py3-none-any.whl.

File metadata

File hashes

Hashes for cli_command_parser-2026.6.27-py3-none-any.whl
Algorithm Hash digest
SHA256 d263a1a2a87585dfd920bed8ea442223b8a65e243af42890e7ab5b463a144a74
MD5 6322edea4a2c16f89286e61826fd7b77
BLAKE2b-256 5596affbc317ce7e7a8af071941a7e0b4f6762fb1eb6856ac3e49a7b81af0f4d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page