diff options
Diffstat (limited to 'conf')
-rw-r--r-- | conf/delete.go | 54 | ||||
-rw-r--r-- | conf/main.go | 1 |
2 files changed, 55 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) +} diff --git a/conf/main.go b/conf/main.go index a768bac..5dc922c 100644 --- a/conf/main.go +++ b/conf/main.go @@ -90,6 +90,7 @@ func main() { parser = &Command{Branch: true} ListInit(parser) CreateInit(parser) + RmInit(parser) parser.Parse(flag.Args()) } |