1
0
Fork 0
mirror of https://github.com/imjasonh/cnotes synced 2026-07-08 17:16:00 +00:00
cnotes/cmd/run.go
Jason Hall 2e7a2badba
Initial implementation of Claude Code hooks in Go
- Easy-to-use hook registration system
- Built-in hooks for bash validation, file protection, and logging
- Automatic goimports formatting for modified Go files
- CLI with install/uninstall commands
- Comprehensive documentation and examples

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-21 11:27:08 -04:00

31 lines
No EOL
697 B
Go

package cmd
import (
"context"
"os"
"github.com/spf13/cobra"
"github.com/imjasonh/hooks/internal/hooks"
_ "github.com/imjasonh/hooks/internal/handlers"
)
var runCmd = &cobra.Command{
Use: "run",
Short: "Run hook handler (called by Claude Code)",
Long: `Run the hook handler by reading JSON from stdin and processing it.
This command is typically called automatically by Claude Code when hooks are triggered.
You can also use it for testing by piping JSON input.`,
RunE: func(cmd *cobra.Command, args []string) error {
ctx := context.Background()
code := hooks.RunExitCode(ctx)
if code != 0 {
os.Exit(code)
}
return nil
},
}
func init() {
rootCmd.AddCommand(runCmd)
}