Skip to content

Commands

Env-spec management CLI.

======================================================================================================================== Name: pymodeller/env/cli.py Description: CLI entry-point for env-spec operations: example, check, diff, codegen, drift. Uses Typer for CLI parsing and a Service-based approach for logic.

Classes:

Name Description
EnvManager

Service class to handle core env-spec logic.

Functions:

Name Description
banner_full

Create a banner.

check

Validate current .env file against the specification.

codegen

Generate typed Pydantic models for the environment.

drift

Check drift between YAML spec and generated code.

example

Generate a template .env.example from the YAML spec.

print_diff

Show the results.

setup

Generate models from yaml and .env.example.

show_master_diff

Show diff.

show_version

Show version.

sync

Check if generated models are in sync with the YAML spec.

EnvManager

Service class to handle core env-spec logic.

Methods:

Name Description
generate_example_content

Build the content for the .env.example file.

get_file_hash

Compute SHA-256 hash of a file.

generate_example_content staticmethod

generate_example_content(spec: Any) -> str

Build the content for the .env.example file.

get_file_hash staticmethod

get_file_hash(path: Path) -> str

Compute SHA-256 hash of a file.

banner_full

banner_full(message: str, color: str = 'green') -> None

Create a banner.

check

check(spec: Path = spec, env: Path = env) -> Exit

Validate current .env file against the specification.

codegen

codegen(
    spec: Path = spec,
    pydantic_out: Path = pydantic_folder,
    peewee_out: Path = peewee_folder,
    pydantic_master: Path = pydantic_out,
    peewee_master: Path = peewee_out,
) -> Exit

Generate typed Pydantic models for the environment.

drift

drift(
    spec: Path = spec, data_model: Path = pydantic_out
) -> Exit

Check drift between YAML spec and generated code.

example

example(spec: Path = spec, out: Path = env_example) -> Exit

Generate a template .env.example from the YAML spec.

print_diff

print_diff(name: str, diff: dict) -> None

Show the results.

setup

setup() -> Exit

Generate models from yaml and .env.example.

show_master_diff

show_master_diff(master_diff: dict) -> None

Show diff.

show_version

show_version(value: bool) -> Exit | None

Show version.

sync

sync(spec: Path = spec) -> Exit

Check if generated models are in sync with the YAML spec.