import typer
import logging
from acc_cli.commands.init import init

logging.basicConfig(
    level=logging.INFO,
    format="%(asctime)s - %(levelname)s - %(message)s"
)
logger = logging.getLogger(__name__)

app = typer.Typer(
    name="acc",
    help="ACC CLI — Databricks Project Generator",
    add_completion=False,
)

app.command("init")(init)


@app.callback(invoke_without_command=True)
def main(ctx: typer.Context):
    """ACC CLI — Databricks Project Generator"""
    logger.info("ACC CLI started")
    if ctx.invoked_subcommand is None:
        try:
            init()
            logger.info("Execution completed successfully")
        except typer.Exit:
            raise
        except Exception as e:
            logger.exception("Unexpected error occurred")
            typer.echo(f"Error: {str(e)}")
            raise typer.Exit(code=1)


def run():
    """Entry point for the CLI."""
    app()


if __name__ == "__main__":
    run()

