typerhook


Nametyperhook JSON
Version 0.1.0 PyPI version JSON
download
home_pageNone
SummaryHooks for typer CLIs.
upload_time2025-08-02 02:12:43
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseNone
keywords cli command-line decorator parameters typer
VCS
bugtrack_url
requirements click iniconfig markdown-it-py mdurl packaging pluggy pygments pytest rich shellingham typer typing-extensions
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # TyperHook

## Overview

Hook decorators to enhance Typer CLIs. Current hooks:

1. defaultparams: adapted from GitHub user Antoine adm271828,
shares parameters between typer commands

## Installation

```bash
pip install typerhook
```

## Quick Start

```python
import typer
import typerhook
from typing import Annotated

app = typer.Typer()

def debug_params(
    ctx: typer.Context,
    debug: Annotated[bool, typer.Option(help="Enable debug mode")] = False,
    verbose: Annotated[bool, typer.Option(help="Verbose output")] = False,
):
    ctx.ensure_object(dict)
    ctx.obj['debug'] = debug
    ctx.obj['verbose'] = verbose

@app.command()
@typerhook.defaultparams(debug_params)
def hello(
    ctx: typer.Context,
    name: Annotated[str, typer.Option(help="Name to greet")] = "World"
):
    debug_mode = ctx.obj.get('debug', False)
    typer.echo(f"Hello {name}! Debug mode: {debug}; Verbose mode: {verbose}")

@app.command()
@typerhook.defaultparams(debug_params)
def bye(
    ctx: typer.Context,
    name: Annotated[str, typer.Option(help="Name to greet")] = "World"
):
    debug = ctx.obj.get('debug', False)
    verbose = ctx.obj.get('verbose', False)
    typer.echo(f"Goodbye {name}! Debug mode: {debug}; Verbose mode: {verbose}")

if __name__ == "__main__":
    app()
```

## API Reference

### `defaultparams(extra: Callable, *, drop: Optional[Sequence[str]]=None)`

Decorator factory that adds extra parameters to a Typer command.

**Parameters:**
- `extra`: Function containing the extra parameters to inject
- `drop`: List of parameter names to exclude from the final signature

## License

MIT License - see LICENSE file for details.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "typerhook",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "cli, command-line, decorator, parameters, typer",
    "author": null,
    "author_email": "muhamuhamuha <ahmedm357@hotmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/7a/ca/73209203cacd383f65bea4d5518f57ca993f8ca8a4ecf78f81ed603a9b58/typerhook-0.1.0.tar.gz",
    "platform": null,
    "description": "# TyperHook\n\n## Overview\n\nHook decorators to enhance Typer CLIs. Current hooks:\n\n1. defaultparams: adapted from GitHub user Antoine adm271828,\nshares parameters between typer commands\n\n## Installation\n\n```bash\npip install typerhook\n```\n\n## Quick Start\n\n```python\nimport typer\nimport typerhook\nfrom typing import Annotated\n\napp = typer.Typer()\n\ndef debug_params(\n    ctx: typer.Context,\n    debug: Annotated[bool, typer.Option(help=\"Enable debug mode\")] = False,\n    verbose: Annotated[bool, typer.Option(help=\"Verbose output\")] = False,\n):\n    ctx.ensure_object(dict)\n    ctx.obj['debug'] = debug\n    ctx.obj['verbose'] = verbose\n\n@app.command()\n@typerhook.defaultparams(debug_params)\ndef hello(\n    ctx: typer.Context,\n    name: Annotated[str, typer.Option(help=\"Name to greet\")] = \"World\"\n):\n    debug_mode = ctx.obj.get('debug', False)\n    typer.echo(f\"Hello {name}! Debug mode: {debug}; Verbose mode: {verbose}\")\n\n@app.command()\n@typerhook.defaultparams(debug_params)\ndef bye(\n    ctx: typer.Context,\n    name: Annotated[str, typer.Option(help=\"Name to greet\")] = \"World\"\n):\n    debug = ctx.obj.get('debug', False)\n    verbose = ctx.obj.get('verbose', False)\n    typer.echo(f\"Goodbye {name}! Debug mode: {debug}; Verbose mode: {verbose}\")\n\nif __name__ == \"__main__\":\n    app()\n```\n\n## API Reference\n\n### `defaultparams(extra: Callable, *, drop: Optional[Sequence[str]]=None)`\n\nDecorator factory that adds extra parameters to a Typer command.\n\n**Parameters:**\n- `extra`: Function containing the extra parameters to inject\n- `drop`: List of parameter names to exclude from the final signature\n\n## License\n\nMIT License - see LICENSE file for details.\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Hooks for typer CLIs.",
    "version": "0.1.0",
    "project_urls": {
        "Documentation": "https://github.com/muhamuhamuha/typerhook#readme",
        "Homepage": "https://github.com/muhamuhamuha/typerhook",
        "Issues": "https://github.com/muhamuhamuha/typerhook/issues",
        "Repository": "https://github.com/muhamuhamuha/typerhook.git"
    },
    "split_keywords": [
        "cli",
        " command-line",
        " decorator",
        " parameters",
        " typer"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "aacef55019ca4941e96d28591ce0eeb087f26954835ca9ba8bf4419a8a93fbd7",
                "md5": "cff5855e5801e33892982a5c23b5bc5a",
                "sha256": "43e9a17d07ee074340d100d209beb21f885c1af1f87fe9125474aef850b1b013"
            },
            "downloads": -1,
            "filename": "typerhook-0.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "cff5855e5801e33892982a5c23b5bc5a",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 5036,
            "upload_time": "2025-08-02T02:12:44",
            "upload_time_iso_8601": "2025-08-02T02:12:44.475043Z",
            "url": "https://files.pythonhosted.org/packages/aa/ce/f55019ca4941e96d28591ce0eeb087f26954835ca9ba8bf4419a8a93fbd7/typerhook-0.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "7aca73209203cacd383f65bea4d5518f57ca993f8ca8a4ecf78f81ed603a9b58",
                "md5": "214c410b08dafe6444bd9c35b9923fd9",
                "sha256": "df3ce0a9c09d463b1b450f11be91a225100568f04bcaac3097025e37baa7eb55"
            },
            "downloads": -1,
            "filename": "typerhook-0.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "214c410b08dafe6444bd9c35b9923fd9",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 8630,
            "upload_time": "2025-08-02T02:12:43",
            "upload_time_iso_8601": "2025-08-02T02:12:43.303529Z",
            "url": "https://files.pythonhosted.org/packages/7a/ca/73209203cacd383f65bea4d5518f57ca993f8ca8a4ecf78f81ed603a9b58/typerhook-0.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-02 02:12:43",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "muhamuhamuha",
    "github_project": "typerhook#readme",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "click",
            "specs": [
                [
                    "==",
                    "8.2.1"
                ]
            ]
        },
        {
            "name": "iniconfig",
            "specs": [
                [
                    "==",
                    "2.1.0"
                ]
            ]
        },
        {
            "name": "markdown-it-py",
            "specs": [
                [
                    "==",
                    "3.0.0"
                ]
            ]
        },
        {
            "name": "mdurl",
            "specs": [
                [
                    "==",
                    "0.1.2"
                ]
            ]
        },
        {
            "name": "packaging",
            "specs": [
                [
                    "==",
                    "25.0"
                ]
            ]
        },
        {
            "name": "pluggy",
            "specs": [
                [
                    "==",
                    "1.6.0"
                ]
            ]
        },
        {
            "name": "pygments",
            "specs": [
                [
                    "==",
                    "2.19.2"
                ]
            ]
        },
        {
            "name": "pytest",
            "specs": [
                [
                    "==",
                    "8.4.1"
                ]
            ]
        },
        {
            "name": "rich",
            "specs": [
                [
                    "==",
                    "14.1.0"
                ]
            ]
        },
        {
            "name": "shellingham",
            "specs": [
                [
                    "==",
                    "1.5.4"
                ]
            ]
        },
        {
            "name": "typer",
            "specs": [
                [
                    "==",
                    "0.16.0"
                ]
            ]
        },
        {
            "name": "typing-extensions",
            "specs": [
                [
                    "==",
                    "4.14.1"
                ]
            ]
        }
    ],
    "lcname": "typerhook"
}
        
Elapsed time: 3.02608s