-
Notifications
You must be signed in to change notification settings - Fork 0
/
user_list.go
46 lines (36 loc) · 1.01 KB
/
user_list.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/*
Copyright © 2022 PlusServer GmbH
*/
package cmd
import (
"context"
"fmt"
"os"
"github.com/spf13/cobra"
)
// listCmd represents the list command
var userListCmd = &cobra.Command{
Use: "list",
Short: "List all users assigned to the reseller account",
Long: `List all users assigned to the reseller account`,
Run: func(cmd *cobra.Command, args []string) {
psOsClient := fetchPsOpenStackClientOrDie()
ctx := context.Background()
resp, err := psOsClient.GetUsers(ctx)
if err != nil {
fmt.Println(err.Error())
os.Exit(1)
}
printUsers(*resp)
},
}
func init() {
userCmd.AddCommand(userListCmd)
// Here you will define your flags and configuration settings.
// Cobra supports Persistent Flags which will work for this command
// and all subcommands, e.g.:
// listCmd.PersistentFlags().String("foo", "", "A help for foo")
// Cobra supports local flags which will only run when this command
// is called directly, e.g.:
// listCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
}