diff --git a/src/claudesync/cli/hooks.py b/src/claudesync/cli/hooks.py index 3015a9f..f01727f 100644 --- a/src/claudesync/cli/hooks.py +++ b/src/claudesync/cli/hooks.py @@ -11,6 +11,39 @@ ] +@click.group() +def hooks(): + """Manage Git hooks for the project.""" + pass + + +@hooks.command() +def install(): + """Install Git hooks for automatic code formatting.""" + project_root = find_git_root() + if not project_root: + click.echo("Error: Not a git repository (or any of the parent directories)") + return + + hooks_dir = project_root / ".git" / "hooks" + if not hooks_dir.exists(): + click.echo(f"Creating hooks directory: {hooks_dir}") + hooks_dir.mkdir(parents=True, exist_ok=True) + + for hook in SUPPORTED_GIT_HOOKS: + copy_hook(hooks_dir, hook) + + click.echo("\nHook installation complete!") + + +@hooks.command() +def list(): + """List available Git hooks.""" + click.echo("Available hooks:") + for hook in SUPPORTED_GIT_HOOKS: + click.echo(f" - {hook}") + + def copy_hook(hooks_dir, hook_name): """ Copy a specific hook from templates to git hooks directory. diff --git a/src/claudesync/cli/main.py b/src/claudesync/cli/main.py index ac3a477..65f5134 100644 --- a/src/claudesync/cli/main.py +++ b/src/claudesync/cli/main.py @@ -21,6 +21,7 @@ from .project import project from .sync import schedule from .config import config +from .hooks import hooks import logging logging.basicConfig( @@ -213,6 +214,7 @@ def sync_submodule(provider, config, submodule, category): cli.add_command(schedule) cli.add_command(config) cli.add_command(chat) +cli.add_command(hooks) if __name__ == "__main__": cli()