feat: improve hook CLI interface and reduce timeout

- Replace -s project flag with cleaner --project boolean flag
- Reduce hook timeout from 30s to 5s for better responsiveness
- Update README with new syntax
This commit is contained in:
carraes
2025-07-09 06:47:15 -03:00
parent c3e401a19e
commit 47d2c0ba43
5 changed files with 14 additions and 14 deletions
+7 -7
View File
@@ -12,9 +12,9 @@ import (
func HandleHooks(cli types.CLI) error {
switch {
case cli.InstallHook:
return InstallHooks(cli.HookScope)
return InstallHooks(cli.Project)
case cli.UninstallHook:
return UninstallHooks(cli.HookScope)
return UninstallHooks(cli.Project)
case cli.ListHooks:
return ListHooks()
case cli.HookStatus:
@@ -23,9 +23,9 @@ func HandleHooks(cli types.CLI) error {
return nil
}
func InstallHooks(scope string) error {
func InstallHooks(projectScope bool) error {
hookScope := hooks.ScopeUser
if scope == "project" {
if projectScope {
hookScope = hooks.ScopeProject
}
@@ -88,9 +88,9 @@ func InstallHooks(scope string) error {
return nil
}
func UninstallHooks(scope string) error {
func UninstallHooks(projectScope bool) error {
hookScope := hooks.ScopeUser
if scope == "project" {
if projectScope {
hookScope = hooks.ScopeProject
}
@@ -185,7 +185,7 @@ func ShowHooksStatus() error {
if userHasShush && projectHasShush {
fmt.Println("\n⚠️ Warning: Both user-wide and project hooks are installed")
fmt.Println(" This will cause shush to run twice on every file modification")
fmt.Println(" Consider removing project hooks: shush --uninstall-hook -s project")
fmt.Println(" Consider removing project hooks: shush --uninstall-hook --project")
} else if userHasShush {
fmt.Println("\n✓ User-wide hooks will handle all projects including this one")
} else if projectHasShush {
+2 -2
View File
@@ -126,7 +126,7 @@ func CreateShushHookEntry() HookEntry {
return HookEntry{
Type: "command",
Command: "shush --changes-only",
Timeout: 30,
Timeout: 5,
}
}
@@ -209,7 +209,7 @@ func AddShushHook(settings *ClaudeSettings) error {
shushHook := map[string]interface{}{
"type": "command",
"command": "shush --changes-only",
"timeout": 30,
"timeout": 5,
}
if postToolUseData, exists := hooksMap["PostToolUse"]; exists {
+1 -1
View File
@@ -20,7 +20,7 @@ type CLI struct {
UninstallHook bool `help:"Uninstall Claude Code hooks"`
ListHooks bool `help:"List current Claude Code hooks configuration"`
HookStatus bool `help:"Check if shush hooks are installed"`
HookScope string `short:"s" help:"Hook scope: 'project' for local, default for user-wide"`
Project bool `help:"Use project scope for hook operations (default: user-wide)"`
Config bool `help:"Show current configuration and location"`
CreateConfig bool `help:"Create example .shush.toml configuration file"`
Version kong.VersionFlag `help:"Show version information"`