Skip to content

Commit

Permalink
feat: add hooks command group as a subcommand of claudesync
Browse files Browse the repository at this point in the history
  • Loading branch information
guidodinello committed Dec 20, 2024
1 parent 6e5dec4 commit 4feb24c
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/claudesync/cli/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions src/claudesync/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from .project import project
from .sync import schedule
from .config import config
from .hooks import hooks
import logging

logging.basicConfig(
Expand Down Expand Up @@ -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()

0 comments on commit 4feb24c

Please sign in to comment.