mirror of
https://github.com/imjasonh/cnotes
synced 2026-07-12 02:42:07 +00:00
31 lines
697 B
Go
31 lines
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)
|
||
|
|
}
|