Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

typer-config

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

typer-config

Utilities for working with configuration files in typer CLIs.

  • 1.4.2
  • PyPI
  • Socket score

Maintainers
1

typer-config

GitHub Workflow Status (with branch) Codecov PyPI PyPI - Downloads Libraries.io dependency status for latest release

This is a collection of utilities to use configuration files to set parameters for a 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 and prototyped in this issue. It allows you to set values for CLI parameters using a configuration file.

Installation

$ 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

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

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 for more examples using typer-config.

Keywords

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc