feat: migrate to golang

This commit is contained in:
2026-07-19 20:01:38 +08:00
parent 302d4e6bb5
commit a2630df9e0
69 changed files with 4750 additions and 3369 deletions

67
internal/cli/hook.go Normal file
View File

@ -0,0 +1,67 @@
package cli
import "github.com/spf13/cobra"
func newHookCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "hook",
Short: "Manage hook scripts",
}
cmd.AddCommand(
&cobra.Command{
Use: "init",
Short: "Initialize hooks directory with template scripts",
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
m, err := newManagers("", "", "")
if err != nil {
return err
}
m.Hook.Init()
return nil
},
},
&cobra.Command{
Use: "list",
Short: "Show hooks directory location and list scripts",
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
m, err := newManagers("", "", "")
if err != nil {
return err
}
m.Hook.ListHooks()
return nil
},
},
&cobra.Command{
Use: "edit <script>",
Short: "Edit a hook script",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
m, err := newManagers("", "", "")
if err != nil {
return err
}
m.Hook.Edit(args[0])
return nil
},
},
&cobra.Command{
Use: "rm <script>",
Short: "Remove a hook script",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
m, err := newManagers("", "", "")
if err != nil {
return err
}
m.Hook.Rm(args[0])
return nil
},
},
)
return cmd
}