feat: cleanup cli

License: MIT
Signed-off-by: Henrique Dias <hacdias@gmail.com>
This commit is contained in:
Henrique Dias
2019-01-06 13:21:31 +00:00
parent 2b8bd28158
commit 999c69de5c
15 changed files with 176 additions and 132 deletions

View File

@@ -8,23 +8,19 @@ import (
func init() {
usersCmd.AddCommand(usersRmCmd)
usersRmCmd.Flags().StringP("username", "u", "", "username to delete")
usersRmCmd.Flags().UintP("id", "i", 0, "id to delete")
}
var usersRmCmd = &cobra.Command{
Use: "rm",
Use: "rm <id|username>",
Short: "Delete a user by username or id",
Long: `Delete a user by username or id`,
Args: usernameOrIDRequired,
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
db := getDB()
defer db.Close()
st := getStorage(db)
username, _ := cmd.Flags().GetString("username")
id, _ := cmd.Flags().GetUint("id")
username, id := parseUsernameOrID(args[0])
var err error
if username != "" {