typer-config


Nametyper-config JSON
Version 1.4.0 PyPI version JSON
download
home_pagehttps://maxb2.github.io/typer-config/
SummaryUtilities for working with configuration files in typer CLIs.
upload_time2023-11-17 16:17:50
maintainer
docs_urlNone
authorMatt Anderson
requires_python>=3.8,<4.0
licenseMIT
keywords typer config configuration configuration-file yaml toml json dotenv cli
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # typer-config

[![GitHub Workflow Status (with branch)](https://img.shields.io/github/actions/workflow/status/maxb2/typer-config/ci.yml?branch=main&style=flat-square)](https://github.com/maxb2/typer-config/actions/workflows/ci.yml)
[![Codecov](https://img.shields.io/codecov/c/github/maxb2/typer-config?style=flat-square)](https://app.codecov.io/gh/maxb2/typer-config)
[![PyPI](https://img.shields.io/pypi/v/typer-config?style=flat-square)](https://pypi.org/project/typer-config/)
[![PyPI - Downloads](https://img.shields.io/pypi/dm/typer-config?style=flat-square)](https://pypi.org/project/typer-config/#history)
[![Libraries.io dependency status for latest release](https://img.shields.io/librariesio/release/pypi/typer-config?style=flat-square)](https://libraries.io/pypi/typer-config)

This is a collection of utilities to use configuration files to set parameters for a [typer](https://github.com/tiangolo/typer) CLI.
It is useful for typer commands with many options/arguments so you don't have to constantly rewrite long commands.
This package was inspired by [phha/click_config_file](https://github.com/phha/click_config_file) and prototyped in [this issue](https://github.com/tiangolo/typer/issues/86#issuecomment-996374166). It allows you to set values for CLI parameters using a configuration file. 

## Installation

```bash
$ pip install typer-config[all]
```

> **Note**: that will include libraries for reading from YAML, TOML, and Dotenv files as well.
  Feel free to leave off the optional dependencies if you don't need those capabilities.

## Usage

```bash
# Long commands like this:
$ my-typer-app --opt1 foo --opt2 bar arg1 arg2

# Can become this:
$ my-typer-app --config config.yml
```

## Quickstart

You can use a decorator to quickly add a configuration parameter to your `typer` application:

```py
import typer
from typer_config import use_yaml_config

app = typer.Typer()


@app.command()
@use_yaml_config()  # MUST BE AFTER @app.command()
def main(foo: FooType):
    ...


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

Your typer command will now include a `--config CONFIG_FILE` option at the command line.

> **Note**: this package also provides `@use_json_config`, `@use_toml_config`, and `@use_dotenv_config` for those file formats.
> You can also use your own loader function and the `@use_config(loader_func)` decorator.

See the [documentation](https://maxb2.github.io/typer-config/latest/examples/simple_yaml/) for more examples using typer-config.
            

Raw data

            {
    "_id": null,
    "home_page": "https://maxb2.github.io/typer-config/",
    "name": "typer-config",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8,<4.0",
    "maintainer_email": "",
    "keywords": "typer,config,configuration,configuration-file,yaml,toml,json,dotenv,cli",
    "author": "Matt Anderson",
    "author_email": "matt@manderscience.com",
    "download_url": "https://files.pythonhosted.org/packages/1b/09/2a04769efe34567bee0a72b15c90d204aed8545f7beced910e8b63e58fc2/typer_config-1.4.0.tar.gz",
    "platform": null,
    "description": "# typer-config\n\n[![GitHub Workflow Status (with branch)](https://img.shields.io/github/actions/workflow/status/maxb2/typer-config/ci.yml?branch=main&style=flat-square)](https://github.com/maxb2/typer-config/actions/workflows/ci.yml)\n[![Codecov](https://img.shields.io/codecov/c/github/maxb2/typer-config?style=flat-square)](https://app.codecov.io/gh/maxb2/typer-config)\n[![PyPI](https://img.shields.io/pypi/v/typer-config?style=flat-square)](https://pypi.org/project/typer-config/)\n[![PyPI - Downloads](https://img.shields.io/pypi/dm/typer-config?style=flat-square)](https://pypi.org/project/typer-config/#history)\n[![Libraries.io dependency status for latest release](https://img.shields.io/librariesio/release/pypi/typer-config?style=flat-square)](https://libraries.io/pypi/typer-config)\n\nThis is a collection of utilities to use configuration files to set parameters for a [typer](https://github.com/tiangolo/typer) CLI.\nIt is useful for typer commands with many options/arguments so you don't have to constantly rewrite long commands.\nThis package was inspired by [phha/click_config_file](https://github.com/phha/click_config_file) and prototyped in [this issue](https://github.com/tiangolo/typer/issues/86#issuecomment-996374166). It allows you to set values for CLI parameters using a configuration file. \n\n## Installation\n\n```bash\n$ pip install typer-config[all]\n```\n\n> **Note**: that will include libraries for reading from YAML, TOML, and Dotenv files as well.\n  Feel free to leave off the optional dependencies if you don't need those capabilities.\n\n## Usage\n\n```bash\n# Long commands like this:\n$ my-typer-app --opt1 foo --opt2 bar arg1 arg2\n\n# Can become this:\n$ my-typer-app --config config.yml\n```\n\n## Quickstart\n\nYou can use a decorator to quickly add a configuration parameter to your `typer` application:\n\n```py\nimport typer\nfrom typer_config import use_yaml_config\n\napp = typer.Typer()\n\n\n@app.command()\n@use_yaml_config()  # MUST BE AFTER @app.command()\ndef main(foo: FooType):\n    ...\n\n\nif __name__ == \"__main__\":\n    app()\n```\n\nYour typer command will now include a `--config CONFIG_FILE` option at the command line.\n\n> **Note**: this package also provides `@use_json_config`, `@use_toml_config`, and `@use_dotenv_config` for those file formats.\n> You can also use your own loader function and the `@use_config(loader_func)` decorator.\n\nSee the [documentation](https://maxb2.github.io/typer-config/latest/examples/simple_yaml/) for more examples using typer-config.",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Utilities for working with configuration files in typer CLIs. ",
    "version": "1.4.0",
    "project_urls": {
        "Documentation": "https://maxb2.github.io/typer-config/",
        "Homepage": "https://maxb2.github.io/typer-config/",
        "Repository": "https://github.com/maxb2/typer-config"
    },
    "split_keywords": [
        "typer",
        "config",
        "configuration",
        "configuration-file",
        "yaml",
        "toml",
        "json",
        "dotenv",
        "cli"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3143540f046ad3e5d805a94454178ccaa8aa4d5179cfa33a802a84ae4af69faa",
                "md5": "eaea2ce0f493cf0191aaf88215285d52",
                "sha256": "e1f0287006810e08e9a063e40941f08531482810f74ffc2a25f6a8c22127fadf"
            },
            "downloads": -1,
            "filename": "typer_config-1.4.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "eaea2ce0f493cf0191aaf88215285d52",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8,<4.0",
            "size": 11205,
            "upload_time": "2023-11-17T16:17:48",
            "upload_time_iso_8601": "2023-11-17T16:17:48.912407Z",
            "url": "https://files.pythonhosted.org/packages/31/43/540f046ad3e5d805a94454178ccaa8aa4d5179cfa33a802a84ae4af69faa/typer_config-1.4.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1b092a04769efe34567bee0a72b15c90d204aed8545f7beced910e8b63e58fc2",
                "md5": "1e6cd3ae027c94824316b43a01e1a912",
                "sha256": "48c65954a15192ad6439ac16c4bc91e4b406fdb055f9ee66e4b467cd14cea265"
            },
            "downloads": -1,
            "filename": "typer_config-1.4.0.tar.gz",
            "has_sig": false,
            "md5_digest": "1e6cd3ae027c94824316b43a01e1a912",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8,<4.0",
            "size": 10579,
            "upload_time": "2023-11-17T16:17:50",
            "upload_time_iso_8601": "2023-11-17T16:17:50.057913Z",
            "url": "https://files.pythonhosted.org/packages/1b/09/2a04769efe34567bee0a72b15c90d204aed8545f7beced910e8b63e58fc2/typer_config-1.4.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-11-17 16:17:50",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "maxb2",
    "github_project": "typer-config",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "typer-config"
}
        
Elapsed time: 0.14811s