From b6c884d85caa6affa5e8cda64b7d64dff40b26cd Mon Sep 17 00:00:00 2001 From: 7000pctAUTO Date: Sat, 31 Jan 2026 01:35:42 +0000 Subject: [PATCH] Add env_pro core modules --- app/env_pro/cli.py | 87 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 app/env_pro/cli.py diff --git a/app/env_pro/cli.py b/app/env_pro/cli.py new file mode 100644 index 0000000..2b74990 --- /dev/null +++ b/app/env_pro/cli.py @@ -0,0 +1,87 @@ +"""Main CLI entry point for env-pro.""" + +import os +import sys +import click +from typing import Optional + + +def get_active_profile() -> Optional[str]: + """Get the active profile from environment or config.""" + env_profile = os.environ.get("ENV_PRO_PROFILE") + if env_profile: + return env_profile + + try: + from env_pro.core.profile import get_active_profile + return get_active_profile() + except Exception: + return None + + +class ProfileContext: + """Context object to pass profile information.""" + def __init__(self, profile: Optional[str] = None): + self.profile = profile or get_active_profile() or "default" + + +pass_profile_context = click.make_pass_decorator(ProfileContext) + + +@click.group() +@click.version_option(version="1.0.0") +@click.option("--profile", "-p", help="Specify profile to use") +@click.pass_context +def main(ctx: click.Context, profile: Optional[str]) -> None: + """env-pro: Smart Environment Variable Manager CLI. + + Manage environment variables with multi-profile support, encryption, + validation, and template generation. + """ + ctx.ensure_object(ProfileContext) + if profile: + ctx.obj.profile = profile + else: + ctx.obj.profile = get_active_profile() + + +@main.group() +def profile(): + """Manage environment profiles.""" + pass + + +@main.group() +def key(): + """Manage encryption keys.""" + pass + + +@main.group() +def template(): + """Manage templates.""" + pass + + +@main.group() +def encrypt(): + """Encryption operations.""" + pass + + +def import_commands(): + """Import all command modules to register them.""" + from env_pro.commands import core + from env_pro.commands import profile_cmds + from env_pro.commands import encrypt_cmds + from env_pro.commands import template_cmds + from env_pro.commands import validate_cmd + from env_pro.commands import gitignore_cmd + from env_pro.commands import export_cmd + + +import_commands() + + +if __name__ == "__main__": + main()