"""
CLI entry point using Click framework.

This module provides the main CLI group and registers commands from submodules:
- cli_sync: sync, doctor, rollback, help-command
- cli_agents: iterate-pr, validate-docs, serve, check-docstrings
- cli_state: state show, state clear, state session
"""

import click

from persuade import __version__
from persuade.cli_agents import register_agent_commands
from persuade.cli_state import register_state_commands
from persuade.cli_sync import register_sync_commands


@click.group(invoke_without_command=True)
@click.version_option(version=__version__)
@click.option("--verbose", "-v", is_flag=True, help="Verbose output")
@click.option("--quiet", "-q", is_flag=True, help="Minimal output")
@click.pass_context
def cli(ctx: click.Context, verbose: bool, quiet: bool) -> None:
    """Persuade - Sync automation to your projects."""
    ctx.ensure_object(dict)
    ctx.obj["verbose"] = verbose
    ctx.obj["quiet"] = quiet

    # If no command specified, show help
    if ctx.invoked_subcommand is None:
        click.echo(ctx.get_help())


# Register commands from submodules
register_sync_commands(cli)
register_agent_commands(cli)
register_state_commands(cli)


if __name__ == "__main__":
    cli()
