mirror of
https://github.com/gravitl/netmaker.git
synced 2025-09-08 06:04:20 +08:00
* generalise smtp config * copy over smtp vars * env new line * fix master key api access * comment user tests * fix network and user invite for master key access * remove email sender type * user mgmt commands * check user role on CE * user role nmtcl cmds * user groups commands * fix role and groups command * fix user create cmd * add usage info * rm user role check * fix user update cmd * fix static check
40 lines
907 B
Go
40 lines
907 B
Go
package user
|
|
|
|
import (
|
|
"os"
|
|
"strings"
|
|
|
|
"github.com/gravitl/netmaker/cli/cmd/commons"
|
|
"github.com/gravitl/netmaker/cli/functions"
|
|
"github.com/guumaster/tablewriter"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
var userListCmd = &cobra.Command{
|
|
Use: "list",
|
|
Args: cobra.NoArgs,
|
|
Short: "List all users",
|
|
Long: `List all users`,
|
|
Run: func(cmd *cobra.Command, args []string) {
|
|
data := functions.ListUsers()
|
|
switch commons.OutputFormat {
|
|
case commons.JsonOutput:
|
|
functions.PrettyPrint(data)
|
|
default:
|
|
table := tablewriter.NewWriter(os.Stdout)
|
|
table.SetHeader([]string{"Name", "Platform Role", "Groups"})
|
|
for _, d := range *data {
|
|
g := []string{}
|
|
for gID := range d.UserGroups {
|
|
g = append(g, gID.String())
|
|
}
|
|
table.Append([]string{d.UserName, d.PlatformRoleID.String(), strings.Join(g, ",")})
|
|
}
|
|
table.Render()
|
|
}
|
|
},
|
|
}
|
|
|
|
func init() {
|
|
rootCmd.AddCommand(userListCmd)
|
|
}
|