88 lines
1.9 KiB
Python
88 lines
1.9 KiB
Python
"""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()
|