feat: wrap commands to send info (#612)

Wrap commands in a better way to pass storage
This commit is contained in:
Henrique Dias authored and GitHub committed 2019-01-07 20:24:23 +00:00
1 parent f396602084
commit 01ff03e426
16 files changed
+170 -212

No files matched your search

+4 -8
View File
@@ -15,21 +15,17 @@ var usersRmCmd = &cobra.Command{
Short: "Delete a user by username or id",
Long: `Delete a user by username or id`,
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
db := getDB()
defer db.Close()
st := getStorage(db)
Run: python(func(cmd *cobra.Command, args []string, d pythonData) {
username, id := parseUsernameOrID(args[0])
var err error
if username != "" {
err = st.Users.Delete(username)
err = d.store.Users.Delete(username)
} else {
err = st.Users.Delete(id)
err = d.store.Users.Delete(id)
}
checkErr(err)
fmt.Println("user deleted successfully")
},
}, pythonConfig{}),
}