Registry / devops / decli
library0.6.3pypypi✓ verified 25d ago

Decli is a minimal wrapper around Python's `argparse` module, designed to simplify the creation of command-line interfaces (CLIs) using a declarative approach. It allows developers to define arguments, subcommands, and groups through Python dictionaries, promoting a clear separation between CLI definition and application logic. The library aims to reduce boilerplate commonly associated with `argparse`, making it easier to build complex CLIs. The current version is 0.6.3, and it is actively maintained.

pip install decli
INSTALL
IMPORT
SIG · DECLI
D
decli
devopspythonv0.6.3
Install
1.6s avg
Import
35ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.6.3 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.036s · 17.8MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.6s · import 0.034s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

cli
from decli import cli

This quickstart demonstrates how to define a basic CLI with a subcommand and an optional global argument using `decli`. The `cli` function takes a dictionary specifying the program's structure, arguments, and command functions. The example shows how to parse arguments and execute the associated function based on simulated command-line input.

from decli import cli data = { "prog": "mycli", "description": "A simple command-line tool.", "arguments": [ { "name": "--verbose", "action": "store_true", "help": "Enable verbose output" } ], "commands": [ { "name": "greet", "description": "Greets the specified person.", "arguments": [ { "name": "name", "help": "The name to greet" } ], "func": lambda args: print(f"Hello, {args.name}!" + (" (verbose)" if args.verbose else "")) } ] } parser = cli(data) # To simulate command-line input, you can pass a list of strings # For real execution, use parser.parse_args() # Example: python mycli greet World --verbose # Simulate 'greet World --verbose' args = parser.parse_args(['greet', 'World', '--verbose']) args.func(args) # Simulate 'greet Alice' args = parser.parse_args(['greet', 'Alice']) args.func(args)
decli --version
Debug
Known issues
gotchaDecli explicitly disallows nesting groups inside exclusive groups and will raise a `ValueError` if attempted. While `argparse` might allow this with broken help messages or non-functional exclusion, `decli` prevents it to maintain integrity.
fix
Avoid defining groups within exclusive groups. Structure your CLI arguments to respect this limitation.
affects: All versions
gotchaDecli is a wrapper around `argparse`, and while it simplifies definition, users still benefit greatly from understanding core `argparse` concepts (e.g., `action`, `nargs`, `const`, `dest`). Many `decli` dictionary keys directly map to `argparse` parameters, and their behavior is inherited from `argparse`.
fix
Familiarize yourself with fundamental `argparse` concepts and parameter behaviors to effectively leverage `decli`'s declarative capabilities and troubleshoot unexpected parsing behavior.
affects: All versions
Errors
Common errors & fixes
ValueError: It is not possible to have groups inside exclusive groups
The decli library does not support defining argument groups (such as `--foo --bar`) within an exclusive argument group (where only one option from the group can be selected), as this can lead to broken help messages and incorrect behavior in the underlying argparse parser.
fix
Restructure your CLI definition to ensure that argument groups are not nested inside exclusive groups. Exclusive groups should contain only individual optional arguments.
ModuleNotFoundError: No module named 'decli'
The 'decli' package is not installed in the Python environment being used, or the Python interpreter cannot locate the installed package.
fix
Install the decli library using pip: `pip install decli`. If you are working within a virtual environment, ensure it is activated before running the installation command.
KeyError: 'name'
An argument definition dictionary passed to decli is missing the mandatory 'name' key, which is essential for identifying the argument (e.g., '-f', '--foo', or a positional argument).
fix
Ensure that every dictionary defining an argument includes a 'name' key with a string or list of strings representing the argument's identifier(s).
TypeError: 'str' object is not callable
This error typically occurs when a value for an argument definition, such as the 'type' parameter, is provided as a string (e.g., 'int') instead of a callable Python type object (e.g., int).
fix
When defining argument types, use the actual Python type (e.g., `int`, `str`, `float`) directly, not its string representation. For example, use `'type': int` instead of `'type': 'int'`.
Upgrade
Version history
0.6.3latest on PyPI · released Jun 1, 2025
Audit
Dependencies

No dependency data recorded yet.

Agent activity
11 hits · last 30 days
node
10
Resources
decli — pip install decli · libregistry