You've already forked filebrowser
mirror of
https://github.com/filebrowser/filebrowser.git
synced 2025-11-26 14:25:26 +08:00
feat: v2 (#599)
Read https://github.com/filebrowser/filebrowser/pull/575.
This commit is contained in:
36
cmd/cmds_rm.go
Normal file
36
cmd/cmds_rm.go
Normal file
@@ -0,0 +1,36 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
func init() {
|
||||
cmdsCmd.AddCommand(cmdsRmCmd)
|
||||
cmdsRmCmd.Flags().StringP("event", "e", "", "corresponding event")
|
||||
cmdsRmCmd.Flags().UintP("index", "i", 0, "command index")
|
||||
cmdsRmCmd.MarkFlagRequired("event")
|
||||
cmdsRmCmd.MarkFlagRequired("index")
|
||||
}
|
||||
|
||||
var cmdsRmCmd = &cobra.Command{
|
||||
Use: "rm",
|
||||
Short: "Removes a command from an event hooker",
|
||||
Long: `Removes a command from an event hooker.`,
|
||||
Args: cobra.NoArgs,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
db := getDB()
|
||||
defer db.Close()
|
||||
st := getStorage(db)
|
||||
s, err := st.Settings.Get()
|
||||
checkErr(err)
|
||||
|
||||
evt := mustGetString(cmd, "event")
|
||||
i, err := cmd.Flags().GetUint("index")
|
||||
checkErr(err)
|
||||
|
||||
s.Commands[evt] = append(s.Commands[evt][:i], s.Commands[evt][i+1:]...)
|
||||
err = st.Settings.Save(s)
|
||||
checkErr(err)
|
||||
printEvents(s.Commands)
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user