Metadata-Version: 2.1
Name: typer-config
Version: 1.4.2
Summary: Utilities for working with configuration files in typer CLIs. 
Home-page: https://maxb2.github.io/typer-config/
License: MIT
Keywords: typer,config,configuration,configuration-file,yaml,toml,json,dotenv,cli
Author: Matt Anderson
Author-email: matt@manderscience.com
Requires-Python: >=3.9,<4.0
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Information Technology
Classifier: Intended Audience :: System Administrators
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.8
Classifier: Topic :: Software Development
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Typing :: Typed
Provides-Extra: all
Provides-Extra: python-dotenv
Provides-Extra: toml
Provides-Extra: yaml
Requires-Dist: python-dotenv ; extra == "python-dotenv" or extra == "all"
Requires-Dist: pyyaml (>=6.0,<7.0) ; extra == "yaml" or extra == "all"
Requires-Dist: toml (>=0.10.2,<0.11.0) ; extra == "toml" or extra == "all"
Requires-Dist: typer (>=0,<1)
Project-URL: Documentation, https://maxb2.github.io/typer-config/
Project-URL: Repository, https://github.com/maxb2/typer-config
Description-Content-Type: text/markdown

# 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.
