func userDelAction(c *cli.Context) { super, err := context.CheckSuperPerm(context.Config.User) if err != nil { fmt.Println(err) return } if !super { fmt.Println("You have no permission to this operation") return } username := c.String("u") fmt.Printf("Type %s to continue: ", "yes") var cmd string fmt.Scanf("%s\n", &cmd) if cmd != "yes" { return } _, version, err := context.GetUser(username) if err != nil { fmt.Println(err) return } err = context.DelUser(username, version) if err != nil { fmt.Println(err) return } else { fmt.Printf("Delete %s success\n", username) } }
func appDelAction(c *cli.Context) { appname := c.String("d") super, err := context.CheckSuperPerm(context.Config.User) if err != nil { fmt.Println(err) return } if !super { fmt.Println("You have no permission to this operation") return } if appname == "" { appname = context.GetAppName() } fmt.Printf("Type %s to continue: ", "yes") var cmd string fmt.Scanf("%s\n", &cmd) if cmd != "yes" { return } _, version, err := context.GetApp(appname) if err != nil { fmt.Println(err) return } err = context.DelApp(appname, version) if err != nil { fmt.Println(err) return } else { fmt.Printf("Delete %s success\n", appname) } }
func userAddAction(c *cli.Context) { super, err := context.CheckSuperPerm(context.Config.User) if err != nil { fmt.Println(err) return } if !super { fmt.Println("You have no permission to this operation") return } username := c.String("u") role := c.String("r") if username == "" { fmt.Println("-u,username must be assigned") return } token, err := context.AddUser(username, role) if err != nil { fmt.Println(err) return } fmt.Printf("Add %s success\nToken:%s\n", username, token) }