mirror of
https://github.com/filebrowser/filebrowser.git
synced 2024-06-07 23:00:43 +00:00
01ff03e426
Wrap commands in a better way to pass storage
32 lines
609 B
Go
32 lines
609 B
Go
package cmd
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
func init() {
|
|
usersCmd.AddCommand(usersRmCmd)
|
|
}
|
|
|
|
var usersRmCmd = &cobra.Command{
|
|
Use: "rm <id|username>",
|
|
Short: "Delete a user by username or id",
|
|
Long: `Delete a user by username or id`,
|
|
Args: cobra.ExactArgs(1),
|
|
Run: python(func(cmd *cobra.Command, args []string, d pythonData) {
|
|
username, id := parseUsernameOrID(args[0])
|
|
var err error
|
|
|
|
if username != "" {
|
|
err = d.store.Users.Delete(username)
|
|
} else {
|
|
err = d.store.Users.Delete(id)
|
|
}
|
|
|
|
checkErr(err)
|
|
fmt.Println("user deleted successfully")
|
|
}, pythonConfig{}),
|
|
}
|