{"id":2467,"library":"decli","title":"Decli: Declarative CLI Tool","description":"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.","status":"active","version":"0.6.3","language":"en","source_language":"en","source_url":"https://github.com/woile/decli","tags":["cli","argparse","declarative","command-line-interface","automation"],"install":[{"cmd":"pip install decli","lang":"bash","label":"Install with pip"}],"dependencies":[],"imports":[{"symbol":"cli","correct":"from decli import cli"}],"quickstart":{"code":"from decli import cli\n\ndata = {\n    \"prog\": \"mycli\",\n    \"description\": \"A simple command-line tool.\",\n    \"arguments\": [\n        {\n            \"name\": \"--verbose\",\n            \"action\": \"store_true\",\n            \"help\": \"Enable verbose output\"\n        }\n    ],\n    \"commands\": [\n        {\n            \"name\": \"greet\",\n            \"description\": \"Greets the specified person.\",\n            \"arguments\": [\n                {\n                    \"name\": \"name\",\n                    \"help\": \"The name to greet\"\n                }\n            ],\n            \"func\": lambda args: print(f\"Hello, {args.name}!\" + (\" (verbose)\" if args.verbose else \"\"))\n        }\n    ]\n}\n\nparser = cli(data)\n# To simulate command-line input, you can pass a list of strings\n# For real execution, use parser.parse_args()\n# Example: python mycli greet World --verbose\n\n# Simulate 'greet World --verbose'\nargs = parser.parse_args(['greet', 'World', '--verbose'])\nargs.func(args)\n\n# Simulate 'greet Alice'\nargs = parser.parse_args(['greet', 'Alice'])\nargs.func(args)\n","lang":"python","description":"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."},"warnings":[{"fix":"Avoid defining groups within exclusive groups. Structure your CLI arguments to respect this limitation.","message":"Decli 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.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Familiarize yourself with fundamental `argparse` concepts and parameter behaviors to effectively leverage `decli`'s declarative capabilities and troubleshoot unexpected parsing behavior.","message":"Decli 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`.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-10T00:00:00.000Z","next_check":"2026-07-09T00:00:00.000Z"}