mirror of
https://github.com/jech/galene.git
synced 2024-11-13 20:25:57 +01:00
Implement galenectl list-users -l.
This commit is contained in:
parent
cd224ffed2
commit
04be28fa5b
1 changed files with 18 additions and 1 deletions
|
@ -687,12 +687,14 @@ func parsePermissions(p string, expand bool) (any, error) {
|
||||||
|
|
||||||
func listUsersCmd(cmdname string, args []string) {
|
func listUsersCmd(cmdname string, args []string) {
|
||||||
var groupname string
|
var groupname string
|
||||||
|
var long bool
|
||||||
cmd := flag.NewFlagSet(cmdname, flag.ExitOnError)
|
cmd := flag.NewFlagSet(cmdname, flag.ExitOnError)
|
||||||
setUsage(cmd, cmdname,
|
setUsage(cmd, cmdname,
|
||||||
"%v [option...] %v [option...]\n",
|
"%v [option...] %v [option...]\n",
|
||||||
os.Args[0], cmdname,
|
os.Args[0], cmdname,
|
||||||
)
|
)
|
||||||
cmd.StringVar(&groupname, "group", "", "group `name`")
|
cmd.StringVar(&groupname, "group", "", "group `name`")
|
||||||
|
cmd.BoolVar(&long, "l", false, "display permissions")
|
||||||
cmd.Parse(args)
|
cmd.Parse(args)
|
||||||
|
|
||||||
if cmd.NArg() != 0 {
|
if cmd.NArg() != 0 {
|
||||||
|
@ -720,7 +722,22 @@ func listUsersCmd(cmdname string, args []string) {
|
||||||
return users[i] < users[j]
|
return users[i] < users[j]
|
||||||
})
|
})
|
||||||
for _, user := range users {
|
for _, user := range users {
|
||||||
fmt.Println(user)
|
if !long {
|
||||||
|
fmt.Println(user)
|
||||||
|
} else {
|
||||||
|
uu, err := url.JoinPath(u, user)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Printf("%-12s (ERROR=%v)\n", user, err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
var d group.UserDescription
|
||||||
|
err = getJSON(uu, &d)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Printf("%-12s (ERROR=%v)\n", user, err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
fmt.Printf("%-12s %v\n", user, d.Permissions)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue