Skip to main content

Use [pydantic](https://docs.pydantic.dev/latest/) to manage persistent config for your [Typer](https://typer.tiangolo.com/) CLI apps!

Project description

Typer Pydantic Config

This package helps you quickly build python CLI applications with a persistent config.

  1. Implement config object as pydantic class
  2. Use get_config where every you need the current values
  3. Build a normal app with typer
  4. start the app with start_config_app

On the first invocation, prompts the user to set all values in the config file.

Your app now has an additional config command with the following signature:

Usage: example.py config [OPTIONS] COMMAND [ARGS]...

  Interact with config: ( set | init | show | path | delete).

Options:
  --help  Show this message and exit.

Commands:
  delete  Delete config file on disk.
  init    Interactively prompt for every field in the config.
  path    Print config path.
  set     Set one or more config fields via flags.
  show    Print content of config file.

⚠ Current shortcomings ⚠

  • Supports only the following basic types:
    • Pydantic model
    • int
    • float
    • bool
    • str
    • datetime
    • Path
  • usage of typer/clicks context in get_config could pose problems when package user modifies context
  • setting of app = typer.Typer(name="<some_unique_name>") is required
  • if there is already another application with the name installed on the system, this could lead to problems

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

typer_pydantic_config-0.3.2.tar.gz (21.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

typer_pydantic_config-0.3.2-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

Details for the file typer_pydantic_config-0.3.2.tar.gz.

File metadata

File hashes

Hashes for typer_pydantic_config-0.3.2.tar.gz
Algorithm Hash digest
SHA256 c9f2eca2bd598a826296760edc765fad2041f1d235280720266688f78056f26c
MD5 3e8e78b887b5ef57022360dcb166459e
BLAKE2b-256 c08d8051639f98322219624158634b9d66495082436e5df0e1dd12c985330089

See more details on using hashes here.

File details

Details for the file typer_pydantic_config-0.3.2-py3-none-any.whl.

File metadata

File hashes

Hashes for typer_pydantic_config-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 9df1c01bc20752feb72b2101e0d081410ef48cab72c147cd16535ccfcd170954
MD5 3db1ad46ea11f3320c2879eb36e0bee4
BLAKE2b-256 874e42105dce3b0d8196dbece4176c11034d95f629590063b3b2e53545f6adbd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page