A library to parse CLI output into structured data.
Project description
CLInspector
CLInspector Documentation
CLInspector is a library to introspect Python CLI applications and extract their command structure and parameters programmatically.
Usage
The main entry point is the get_cmd_info() function which analyzes a CLI application instance and returns a structured CommandInfo object:
from clinspector import get_cmd_info
command_info = get_cmd_info(cli_instance)
The function accepts CLI application instances from the following frameworks:
- Typer -
typer.Typerinstances - Click -
click.Groupinstances - Cleo -
cleo.Applicationinstances - Cappa - Classes decorated with
@cappa.command - argparse -
ArgumentParserinstances
The extracted information is returned as a CommandInfo object containing:
CommandInfo Fields
name: str- Name of the commanddescription: str- Description/help textusage: str- Formatted usage stringsubcommands: dict[str, CommandInfo]- Nested subcommandsdeprecated: bool- Whether command is marked as deprecatedepilog: str | None- Optional epilog texthidden: bool- Whether command is hiddenparams: list[Param]- List of command parameters
Param Fields
name: str- Parameter namehelp: str | None- Help textdefault: Any- Default valueopts: list[str]- Parameter options (e.g.["-f", "--flag"])required: bool- Whether parameter is requiredis_flag: bool- Whether parameter is a flagmultiple: bool- Whether parameter accepts multiple valuesnargs: int | str | None- Number of arguments acceptedenvvar: str | None- Environment variable namehidden: bool- Whether parameter is hiddenparam_type_name: Literal["option", "parameter", "argument"]- Parameter typetype: dict[str, str] | None- Parameter type informationmetavar: str | None- Display name in help text
You can access subcommands using dictionary syntax:
# Get info for "build" subcommand
build_info = command_info["build"]
# Access nested subcommand
nested_info = command_info["group"]["subcommand"]
The extracted information allows you to:
- Generate documentation automatically
- Build command completion
- Create wrappers and adapters
- Perform static analysis of CLI interfaces
- And more!
Example output for a click command:
```python
CommandInfo(
name="cli",
description="Example CLI tool",
usage="cli [OPTIONS] COMMAND [ARGS]...",
params=[
Param(name="verbose", help="Enable verbose output", opts=["-v", "--verbose"])
],
subcommands={
"build": CommandInfo(
name="build",
description="Build the project",
params=[...]
)
}
)
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file clinspector-0.3.0.tar.gz.
File metadata
- Download URL: clinspector-0.3.0.tar.gz
- Upload date:
- Size: 23.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c0b45d224b5af5fe2393dd576481fd4cf2f54ec76c9c7e59a117f7b34a8cc792
|
|
| MD5 |
904f729a42a5faf90ab71df5351af2dc
|
|
| BLAKE2b-256 |
cf3a0e36eb888bfe646a74729ec07a3140570e3a07506b5ff127a952335dfe3e
|
Provenance
The following attestation bundles were made for clinspector-0.3.0.tar.gz:
Publisher:
build.yml on phil65/clinspector
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
clinspector-0.3.0.tar.gz -
Subject digest:
c0b45d224b5af5fe2393dd576481fd4cf2f54ec76c9c7e59a117f7b34a8cc792 - Sigstore transparency entry: 173531808
- Sigstore integration time:
-
Permalink:
phil65/clinspector@c4ca26ea266984aea8b6074479850444a714933d -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/phil65
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build.yml@c4ca26ea266984aea8b6074479850444a714933d -
Trigger Event:
push
-
Statement type:
File details
Details for the file clinspector-0.3.0-py3-none-any.whl.
File metadata
- Download URL: clinspector-0.3.0-py3-none-any.whl
- Upload date:
- Size: 25.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
211b034dde5d601ea0c14c610ef75d92f5deccb844f51579393430a63d0dcd33
|
|
| MD5 |
1c1dc697165e13f05a26e4f0354f09fa
|
|
| BLAKE2b-256 |
b1ea4f0a2e307c24c9a8c52c7202f95224fec722a4ad13449cad1cc2fb459a28
|
Provenance
The following attestation bundles were made for clinspector-0.3.0-py3-none-any.whl:
Publisher:
build.yml on phil65/clinspector
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
clinspector-0.3.0-py3-none-any.whl -
Subject digest:
211b034dde5d601ea0c14c610ef75d92f5deccb844f51579393430a63d0dcd33 - Sigstore transparency entry: 173531809
- Sigstore integration time:
-
Permalink:
phil65/clinspector@c4ca26ea266984aea8b6074479850444a714933d -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/phil65
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build.yml@c4ca26ea266984aea8b6074479850444a714933d -
Trigger Event:
push
-
Statement type: