clinspector


Nameclinspector JSON
Version 0.5.0 PyPI version JSON
download
home_pageNone
SummaryA library to parse CLI output into structured data.
upload_time2025-10-06 20:27:51
maintainerNone
docs_urlNone
authorPhilipp Temminghoff
requires_python>=3.12
licenseMIT License Copyright (c) 2024, Philipp Temminghoff Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # CLInspector

[![PyPI License](https://img.shields.io/pypi/l/clinspector.svg)](https://pypi.org/project/clinspector/)
[![Package status](https://img.shields.io/pypi/status/clinspector.svg)](https://pypi.org/project/clinspector/)
[![Monthly downloads](https://img.shields.io/pypi/dm/clinspector.svg)](https://pypi.org/project/clinspector/)
[![Distribution format](https://img.shields.io/pypi/format/clinspector.svg)](https://pypi.org/project/clinspector/)
[![Wheel availability](https://img.shields.io/pypi/wheel/clinspector.svg)](https://pypi.org/project/clinspector/)
[![Python version](https://img.shields.io/pypi/pyversions/clinspector.svg)](https://pypi.org/project/clinspector/)
[![Implementation](https://img.shields.io/pypi/implementation/clinspector.svg)](https://pypi.org/project/clinspector/)
[![Releases](https://img.shields.io/github/downloads/phil65/clinspector/total.svg)](https://github.com/phil65/clinspector/releases)
[![Github Contributors](https://img.shields.io/github/contributors/phil65/clinspector)](https://github.com/phil65/clinspector/graphs/contributors)
[![Github Discussions](https://img.shields.io/github/discussions/phil65/clinspector)](https://github.com/phil65/clinspector/discussions)
[![Github Forks](https://img.shields.io/github/forks/phil65/clinspector)](https://github.com/phil65/clinspector/forks)
[![Github Issues](https://img.shields.io/github/issues/phil65/clinspector)](https://github.com/phil65/clinspector/issues)
[![Github Issues](https://img.shields.io/github/issues-pr/phil65/clinspector)](https://github.com/phil65/clinspector/pulls)
[![Github Watchers](https://img.shields.io/github/watchers/phil65/clinspector)](https://github.com/phil65/clinspector/watchers)
[![Github Stars](https://img.shields.io/github/stars/phil65/clinspector)](https://github.com/phil65/clinspector/stars)
[![Github Repository size](https://img.shields.io/github/repo-size/phil65/clinspector)](https://github.com/phil65/clinspector)
[![Github last commit](https://img.shields.io/github/last-commit/phil65/clinspector)](https://github.com/phil65/clinspector/commits)
[![Github release date](https://img.shields.io/github/release-date/phil65/clinspector)](https://github.com/phil65/clinspector/releases)
[![Github language count](https://img.shields.io/github/languages/count/phil65/clinspector)](https://github.com/phil65/clinspector)
[![Github commits this month](https://img.shields.io/github/commit-activity/m/phil65/clinspector)](https://github.com/phil65/clinspector)
[![Package status](https://codecov.io/gh/phil65/clinspector/branch/main/graph/badge.svg)](https://codecov.io/gh/phil65/clinspector/)
[![PyUp](https://pyup.io/repos/github/phil65/clinspector/shield.svg)](https://pyup.io/repos/github/phil65/clinspector/)

[Read the documentation!](https://phil65.github.io/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:

```python
from clinspector import get_cmd_info

command_info = get_cmd_info(cli_instance)
```

The function accepts CLI application instances from the following frameworks:

- [Typer](https://typer.tiangolo.com/) - `typer.Typer` instances
- [Click](https://click.palletsprojects.com/) - `click.Group` instances
- [Cleo](https://cleo.readthedocs.io/) - `cleo.Application` instances
- [Cappa](https://github.com/DynamicArray/Cappa) - Classes decorated with `@cappa.command`
- [argparse](https://docs.python.org/3/library/argparse.html) - `ArgumentParser` instances

The extracted information is returned as a `CommandInfo` object containing:

### CommandInfo Fields

- `name: str` - Name of the command
- `description: str` - Description/help text
- `usage: str` - Formatted usage string
- `subcommands: dict[str, CommandInfo]` - Nested subcommands
- `deprecated: bool` - Whether command is marked as deprecated
- `epilog: str | None` - Optional epilog text
- `hidden: bool` - Whether command is hidden
- `params: list[Param]` - List of command parameters

### Param Fields

- `name: str` - Parameter name
- `help: str | None` - Help text
- `default: Any` - Default value
- `opts: list[str]` - Parameter options (e.g. `["-f", "--flag"]`)
- `required: bool` - Whether parameter is required
- `is_flag: bool` - Whether parameter is a flag
- `multiple: bool` - Whether parameter accepts multiple values
- `nargs: int | str | None` - Number of arguments accepted
- `envvar: str | None` - Environment variable name
- `hidden: bool` - Whether parameter is hidden
- `param_type_name: Literal["option", "parameter", "argument"]` - Parameter type
- `type: dict[str, str] | None` - Parameter type information
- `metavar: str | None` - Display name in help text

You can access subcommands using dictionary syntax:

```python
# 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=[...]
        )
    }
)
```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "clinspector",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.12",
    "maintainer_email": null,
    "keywords": null,
    "author": "Philipp Temminghoff",
    "author_email": "Philipp Temminghoff <philipptemminghoff@googlemail.com>",
    "download_url": "https://files.pythonhosted.org/packages/45/86/bd16e1c585b46af3b961aca4f2c06d7e877b03cea29ca86831ed70823b33/clinspector-0.5.0.tar.gz",
    "platform": null,
    "description": "# CLInspector\n\n[![PyPI License](https://img.shields.io/pypi/l/clinspector.svg)](https://pypi.org/project/clinspector/)\n[![Package status](https://img.shields.io/pypi/status/clinspector.svg)](https://pypi.org/project/clinspector/)\n[![Monthly downloads](https://img.shields.io/pypi/dm/clinspector.svg)](https://pypi.org/project/clinspector/)\n[![Distribution format](https://img.shields.io/pypi/format/clinspector.svg)](https://pypi.org/project/clinspector/)\n[![Wheel availability](https://img.shields.io/pypi/wheel/clinspector.svg)](https://pypi.org/project/clinspector/)\n[![Python version](https://img.shields.io/pypi/pyversions/clinspector.svg)](https://pypi.org/project/clinspector/)\n[![Implementation](https://img.shields.io/pypi/implementation/clinspector.svg)](https://pypi.org/project/clinspector/)\n[![Releases](https://img.shields.io/github/downloads/phil65/clinspector/total.svg)](https://github.com/phil65/clinspector/releases)\n[![Github Contributors](https://img.shields.io/github/contributors/phil65/clinspector)](https://github.com/phil65/clinspector/graphs/contributors)\n[![Github Discussions](https://img.shields.io/github/discussions/phil65/clinspector)](https://github.com/phil65/clinspector/discussions)\n[![Github Forks](https://img.shields.io/github/forks/phil65/clinspector)](https://github.com/phil65/clinspector/forks)\n[![Github Issues](https://img.shields.io/github/issues/phil65/clinspector)](https://github.com/phil65/clinspector/issues)\n[![Github Issues](https://img.shields.io/github/issues-pr/phil65/clinspector)](https://github.com/phil65/clinspector/pulls)\n[![Github Watchers](https://img.shields.io/github/watchers/phil65/clinspector)](https://github.com/phil65/clinspector/watchers)\n[![Github Stars](https://img.shields.io/github/stars/phil65/clinspector)](https://github.com/phil65/clinspector/stars)\n[![Github Repository size](https://img.shields.io/github/repo-size/phil65/clinspector)](https://github.com/phil65/clinspector)\n[![Github last commit](https://img.shields.io/github/last-commit/phil65/clinspector)](https://github.com/phil65/clinspector/commits)\n[![Github release date](https://img.shields.io/github/release-date/phil65/clinspector)](https://github.com/phil65/clinspector/releases)\n[![Github language count](https://img.shields.io/github/languages/count/phil65/clinspector)](https://github.com/phil65/clinspector)\n[![Github commits this month](https://img.shields.io/github/commit-activity/m/phil65/clinspector)](https://github.com/phil65/clinspector)\n[![Package status](https://codecov.io/gh/phil65/clinspector/branch/main/graph/badge.svg)](https://codecov.io/gh/phil65/clinspector/)\n[![PyUp](https://pyup.io/repos/github/phil65/clinspector/shield.svg)](https://pyup.io/repos/github/phil65/clinspector/)\n\n[Read the documentation!](https://phil65.github.io/clinspector/)\n\n# CLInspector Documentation\n\nCLInspector is a library to introspect Python CLI applications and extract their command structure and parameters programmatically.\n\n## Usage\n\nThe main entry point is the `get_cmd_info()` function which analyzes a CLI application instance and returns a structured `CommandInfo` object:\n\n```python\nfrom clinspector import get_cmd_info\n\ncommand_info = get_cmd_info(cli_instance)\n```\n\nThe function accepts CLI application instances from the following frameworks:\n\n- [Typer](https://typer.tiangolo.com/) - `typer.Typer` instances\n- [Click](https://click.palletsprojects.com/) - `click.Group` instances\n- [Cleo](https://cleo.readthedocs.io/) - `cleo.Application` instances\n- [Cappa](https://github.com/DynamicArray/Cappa) - Classes decorated with `@cappa.command`\n- [argparse](https://docs.python.org/3/library/argparse.html) - `ArgumentParser` instances\n\nThe extracted information is returned as a `CommandInfo` object containing:\n\n### CommandInfo Fields\n\n- `name: str` - Name of the command\n- `description: str` - Description/help text\n- `usage: str` - Formatted usage string\n- `subcommands: dict[str, CommandInfo]` - Nested subcommands\n- `deprecated: bool` - Whether command is marked as deprecated\n- `epilog: str | None` - Optional epilog text\n- `hidden: bool` - Whether command is hidden\n- `params: list[Param]` - List of command parameters\n\n### Param Fields\n\n- `name: str` - Parameter name\n- `help: str | None` - Help text\n- `default: Any` - Default value\n- `opts: list[str]` - Parameter options (e.g. `[\"-f\", \"--flag\"]`)\n- `required: bool` - Whether parameter is required\n- `is_flag: bool` - Whether parameter is a flag\n- `multiple: bool` - Whether parameter accepts multiple values\n- `nargs: int | str | None` - Number of arguments accepted\n- `envvar: str | None` - Environment variable name\n- `hidden: bool` - Whether parameter is hidden\n- `param_type_name: Literal[\"option\", \"parameter\", \"argument\"]` - Parameter type\n- `type: dict[str, str] | None` - Parameter type information\n- `metavar: str | None` - Display name in help text\n\nYou can access subcommands using dictionary syntax:\n\n```python\n# Get info for \"build\" subcommand\nbuild_info = command_info[\"build\"]\n\n# Access nested subcommand\nnested_info = command_info[\"group\"][\"subcommand\"]\n```\n```\n\nThe extracted information allows you to:\n\n- Generate documentation automatically\n- Build command completion\n- Create wrappers and adapters\n- Perform static analysis of CLI interfaces\n- And more!\n\nExample output for a click command:\n\n```python\nCommandInfo(\n    name=\"cli\",\n    description=\"Example CLI tool\",\n    usage=\"cli [OPTIONS] COMMAND [ARGS]...\",\n    params=[\n        Param(name=\"verbose\", help=\"Enable verbose output\", opts=[\"-v\", \"--verbose\"])\n    ],\n    subcommands={\n        \"build\": CommandInfo(\n            name=\"build\",\n            description=\"Build the project\",\n            params=[...]\n        )\n    }\n)\n```\n",
    "bugtrack_url": null,
    "license": "MIT License\n         \n         Copyright (c) 2024, Philipp Temminghoff\n         \n         Permission is hereby granted, free of charge, to any person obtaining a copy\n         of this software and associated documentation files (the \"Software\"), to deal\n         in the Software without restriction, including without limitation the rights\n         to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n         copies of the Software, and to permit persons to whom the Software is\n         furnished to do so, subject to the following conditions:\n         \n         The above copyright notice and this permission notice shall be included in all\n         copies or substantial portions of the Software.\n         \n         THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n         IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n         FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n         AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n         LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n         OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n         SOFTWARE.\n         ",
    "summary": "A library to parse CLI output into structured data.",
    "version": "0.5.0",
    "project_urls": {
        "Code coverage": "https://app.codecov.io/gh/phil65/clinspector",
        "Discussions": "https://github.com/phil65/clinspector/discussions",
        "Documentation": "https://phil65.github.io/clinspector/",
        "Issues": "https://github.com/phil65/clinspector/issues",
        "Source": "https://github.com/phil65/clinspector"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "518f13c8699830c7c265c91f2446f3b8f942f76749ab08d4e4622f3e381d6c23",
                "md5": "8e9c795f5914700e8ea4bcac38caec87",
                "sha256": "5f57d14a47963bcf3d65a8b78b55332e9a955b19ebb28563a0aaa2ae0ae14fbe"
            },
            "downloads": -1,
            "filename": "clinspector-0.5.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "8e9c795f5914700e8ea4bcac38caec87",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.12",
            "size": 32862,
            "upload_time": "2025-10-06T20:27:50",
            "upload_time_iso_8601": "2025-10-06T20:27:50.534613Z",
            "url": "https://files.pythonhosted.org/packages/51/8f/13c8699830c7c265c91f2446f3b8f942f76749ab08d4e4622f3e381d6c23/clinspector-0.5.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "4586bd16e1c585b46af3b961aca4f2c06d7e877b03cea29ca86831ed70823b33",
                "md5": "53fca6b60e340ada7fd87d75c2b0c9d8",
                "sha256": "05b6c6fe4a036ce7a2a63bce8f3a1df4a71c724c958ffab966f6810290af19bd"
            },
            "downloads": -1,
            "filename": "clinspector-0.5.0.tar.gz",
            "has_sig": false,
            "md5_digest": "53fca6b60e340ada7fd87d75c2b0c9d8",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.12",
            "size": 23591,
            "upload_time": "2025-10-06T20:27:51",
            "upload_time_iso_8601": "2025-10-06T20:27:51.872390Z",
            "url": "https://files.pythonhosted.org/packages/45/86/bd16e1c585b46af3b961aca4f2c06d7e877b03cea29ca86831ed70823b33/clinspector-0.5.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-10-06 20:27:51",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "phil65",
    "github_project": "clinspector",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "clinspector"
}
        
Elapsed time: 1.39307s