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
# Install automatic comment cleanup after Claude modifies files
shush --install-hook # User-wide (all projects)
shush --install-hook -s project # Project-specific only
shush --install-hook --project # Project-specific only
# Manage hooks
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
--list-hooks List current Claude Code hooks configuration
--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
--version Show version information
@@ -351,7 +351,7 @@ Seamless integration with Claude Code via hooks - **available now**:
```bash
# Install automatic comment cleanup after Claude modifies files
shush --install-hook # User-wide (all projects)
shush --install-hook -s project # Project-specific only
shush --install-hook --project # Project-specific only
# Manage hooks
shush --hook-status # Check installation status
+1 -1
View File
@@ -12,7 +12,7 @@ import (
"github.com/carlosarraes/shush/internal/types"
)
var version = "0.3.2"
var version = "0.3.3"
func main() {
var cliArgs types.CLI
+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"`