diff options
author | sanine-a <sanine.not@pm.me> | 2023-05-10 14:43:35 -0500 |
---|---|---|
committer | sanine-a <sanine.not@pm.me> | 2023-05-10 14:43:35 -0500 |
commit | 2aac43407d7b2699d956b7c626da4f45c802c53c (patch) | |
tree | bb837305076e229e1aabe55a6e9ce5b0c9cf982b /conf/delete.go | |
parent | c4dbe6328640f8ac43518a642e77dec061bfdd03 (diff) |
add rm command
Diffstat (limited to 'conf/delete.go')
-rw-r--r-- | conf/delete.go | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/conf/delete.go b/conf/delete.go new file mode 100644 index 0000000..384e392 --- /dev/null +++ b/conf/delete.go @@ -0,0 +1,54 @@ +package main + +import ( + "fmt" + "log" +) + + +var rmUser = &Command{ + Name: "user", + Execute: func(args []string) { + if len(args) < 1 { + fmt.Println("error: username not provided") + return + } + username := args[0] + user, err := p.GetByUsername(username) + if err != nil { log.Fatal(err) } + err = p.DeleteUser(user) + if err != nil { log.Fatal(err) } + fmt.Printf("deleted user %v\n", username) + }, +} + + +var rmEndpoint = &Command{ + Name: "endpoint", + Execute: func(args []string) { + if len(args) < 1 { + fmt.Println("error: endpointname not provided") + return + } + name := args[0] + endpoint, err := p.GetEndpointByName(name) + if err != nil { log.Fatal(err) } + err = p.DeleteEndpoint(endpoint) + if err != nil { log.Fatal(err) } + fmt.Printf("deleted endpoint %v\n", name) + }, +} + + + + +func RmInit(parser *Command) { + rm := &Command{ + Name: "rm", + Branch: true, + } + + rm.AddCommand(rmUser) + rm.AddCommand(rmEndpoint) + parser.AddCommand(rm) +} |