The eyconf.cli module provides a convenient way to create a command-line interface (CLI) for managing configuration files using the typer library. This can be particularly useful when you want to provide users with the ability to interact and modify configuration files via the terminal.
You need to install the cli additions to use this feature. You can install it using pip:
To integrate the CLI into your project, follow these steps:
fromeyconf.cliimportcreate_config_clifromeyconfimportEYConffromyour_project.configimportConfigSchema# Adjust the import to your actual config schemafromyour_projectimportapp# Adjust the import to your actual Typer app# Your main typer appapp=typer.Typer()sub_app=create_config_cli(EYConf,schema)app.add_typer(sub_app,name="config")
The CLI provides several commands to manage your configuration:
configUsage: config [OPTIONS] COMMAND [ARGS]...Manage configuration file╭─ Options ────────────────────────────────────────────────────────────────────╮│--edit-eEdit the configuration.││--helpShow this message and exit.│╰──────────────────────────────────────────────────────────────────────────────╯╭─ Commands ───────────────────────────────────────────────────────────────────╮│ls Show the current configuration. │╰──────────────────────────────────────────────────────────────────────────────╯
configUsage: config [OPTIONS] COMMAND [ARGS]...Manage configuration file╭─ Options ────────────────────────────────────────────────────────────────────╮│--edit-eEdit the configuration.││--helpShow this message and exit.│╰──────────────────────────────────────────────────────────────────────────────╯╭─ Commands ───────────────────────────────────────────────────────────────────╮│ls Show the current configuration. │╰──────────────────────────────────────────────────────────────────────────────╯