Files
filebrowser/cmd/cmds_add.go
T

33 lines
682 B
Go
Raw Normal View History

2019-01-05 22:44:33 +00:00
package cmd
import (
2019-01-06 13:21:31 +00:00
"strings"
2019-01-05 22:44:33 +00:00
"github.com/spf13/cobra"
)
func init() {
cmdsCmd.AddCommand(cmdsAddCmd)
}
var cmdsAddCmd = &cobra.Command{
2019-01-06 13:21:31 +00:00
Use: "add <event> <command>",
2019-01-05 22:44:33 +00:00
Short: "Add a command to run on a specific event",
Long: `Add a command to run on a specific event.`,
2024-04-01 18:24:06 +02:00
Args: cobra.MinimumNArgs(2),
2025-11-18 11:29:28 +01:00
RunE: withStore(func(_ *cobra.Command, args []string, st *store) error {
s, err := st.Settings.Get()
if err != nil {
return err
}
2019-01-06 13:21:31 +00:00
command := strings.Join(args[1:], " ")
s.Commands[args[0]] = append(s.Commands[args[0]], command)
2025-11-18 11:29:28 +01:00
err = st.Settings.Save(s)
if err != nil {
return err
}
2019-01-05 22:44:33 +00:00
printEvents(s.Commands)
return nil
2025-11-18 11:29:28 +01:00
}, storeOptions{}),
2019-01-05 22:44:33 +00:00
}