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
+3 -3
View File
@@ -22,7 +22,7 @@ Download the binary for your platform from the [releases page](https://github.co
```bash ```bash
# Install automatic comment cleanup after Claude modifies files # Install automatic comment cleanup after Claude modifies files
shush --install-hook # User-wide (all projects) shush --install-hook # User-wide (all projects)
shush --install-hook -s project # Project-specific only shush --install-hook --project # Project-specific only
# Manage hooks # Manage hooks
shush --hook-status # Check installation status shush --hook-status # Check installation status
@@ -185,7 +185,7 @@ shush specific-file.js # Shows "File is in .shushignore, ignoring"
--uninstall-hook Uninstall Claude Code hooks --uninstall-hook Uninstall Claude Code hooks
--list-hooks List current Claude Code hooks configuration --list-hooks List current Claude Code hooks configuration
--hook-status Check if shush hooks are installed --hook-status Check if shush hooks are installed
-s, --hook-scope Hook scope: 'project' for local, default for user-wide --project Use project scope for hook operations (default: user-wide)
# Utility flags # Utility flags
--version Show version information --version Show version information
@@ -351,7 +351,7 @@ Seamless integration with Claude Code via hooks - **available now**:
```bash ```bash
# Install automatic comment cleanup after Claude modifies files # Install automatic comment cleanup after Claude modifies files
shush --install-hook # User-wide (all projects) shush --install-hook # User-wide (all projects)
shush --install-hook -s project # Project-specific only shush --install-hook --project # Project-specific only
# Manage hooks # Manage hooks
shush --hook-status # Check installation status shush --hook-status # Check installation status
+1 -1
View File
@@ -12,7 +12,7 @@ import (
"github.com/carlosarraes/shush/internal/types" "github.com/carlosarraes/shush/internal/types"
) )
var version = "0.3.2" var version = "0.3.3"
func main() { func main() {
var cliArgs types.CLI var cliArgs types.CLI
+7 -7
View File
@@ -12,9 +12,9 @@ import (
func HandleHooks(cli types.CLI) error { func HandleHooks(cli types.CLI) error {
switch { switch {
case cli.InstallHook: case cli.InstallHook:
return InstallHooks(cli.HookScope) return InstallHooks(cli.Project)
case cli.UninstallHook: case cli.UninstallHook:
return UninstallHooks(cli.HookScope) return UninstallHooks(cli.Project)
case cli.ListHooks: case cli.ListHooks:
return ListHooks() return ListHooks()
case cli.HookStatus: case cli.HookStatus:
@@ -23,9 +23,9 @@ func HandleHooks(cli types.CLI) error {
return nil return nil
} }
func InstallHooks(scope string) error { func InstallHooks(projectScope bool) error {
hookScope := hooks.ScopeUser hookScope := hooks.ScopeUser
if scope == "project" { if projectScope {
hookScope = hooks.ScopeProject hookScope = hooks.ScopeProject
} }
@@ -88,9 +88,9 @@ func InstallHooks(scope string) error {
return nil return nil
} }
func UninstallHooks(scope string) error { func UninstallHooks(projectScope bool) error {
hookScope := hooks.ScopeUser hookScope := hooks.ScopeUser
if scope == "project" { if projectScope {
hookScope = hooks.ScopeProject hookScope = hooks.ScopeProject
} }
@@ -185,7 +185,7 @@ func ShowHooksStatus() error {
if userHasShush && projectHasShush { if userHasShush && projectHasShush {
fmt.Println("\n⚠️ Warning: Both user-wide and project hooks are installed") 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(" 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 { } else if userHasShush {
fmt.Println("\n✓ User-wide hooks will handle all projects including this one") fmt.Println("\n✓ User-wide hooks will handle all projects including this one")
} else if projectHasShush { } else if projectHasShush {
+2 -2
View File
@@ -126,7 +126,7 @@ func CreateShushHookEntry() HookEntry {
return HookEntry{ return HookEntry{
Type: "command", Type: "command",
Command: "shush --changes-only", Command: "shush --changes-only",
Timeout: 30, Timeout: 5,
} }
} }
@@ -209,7 +209,7 @@ func AddShushHook(settings *ClaudeSettings) error {
shushHook := map[string]interface{}{ shushHook := map[string]interface{}{
"type": "command", "type": "command",
"command": "shush --changes-only", "command": "shush --changes-only",
"timeout": 30, "timeout": 5,
} }
if postToolUseData, exists := hooksMap["PostToolUse"]; exists { if postToolUseData, exists := hooksMap["PostToolUse"]; exists {
+1 -1
View File
@@ -20,7 +20,7 @@ type CLI struct {
UninstallHook bool `help:"Uninstall Claude Code hooks"` UninstallHook bool `help:"Uninstall Claude Code hooks"`
ListHooks bool `help:"List current Claude Code hooks configuration"` ListHooks bool `help:"List current Claude Code hooks configuration"`
HookStatus bool `help:"Check if shush hooks are installed"` 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"` Config bool `help:"Show current configuration and location"`
CreateConfig bool `help:"Create example .shush.toml configuration file"` CreateConfig bool `help:"Create example .shush.toml configuration file"`
Version kong.VersionFlag `help:"Show version information"` Version kong.VersionFlag `help:"Show version information"`