mirror of
https://github.com/moul/sshportal.git
synced 2025-10-06 11:16:04 +08:00
Add more stats in 'ls' commands
This commit is contained in:
parent
b9d447266d
commit
15d3379c71
1 changed files with 6 additions and 4 deletions
10
shell.go
10
shell.go
|
@ -382,11 +382,11 @@ GLOBAL OPTIONS:
|
||||||
Usage: "Lists host groups",
|
Usage: "Lists host groups",
|
||||||
Action: func(c *cli.Context) error {
|
Action: func(c *cli.Context) error {
|
||||||
var hostGroups []HostGroup
|
var hostGroups []HostGroup
|
||||||
if err := db.Preload("Hosts").Find(&hostGroups).Error; err != nil {
|
if err := db.Preload("ACLs").Preload("Hosts").Find(&hostGroups).Error; err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
table := tablewriter.NewWriter(s)
|
table := tablewriter.NewWriter(s)
|
||||||
table.SetHeader([]string{"ID", "Name", "Hosts", "Comment"})
|
table.SetHeader([]string{"ID", "Name", "Hosts", "ACLs", "Comment"})
|
||||||
table.SetBorder(false)
|
table.SetBorder(false)
|
||||||
table.SetCaption(true, fmt.Sprintf("Total: %d host groups.", len(hostGroups)))
|
table.SetCaption(true, fmt.Sprintf("Total: %d host groups.", len(hostGroups)))
|
||||||
for _, hostGroup := range hostGroups {
|
for _, hostGroup := range hostGroups {
|
||||||
|
@ -395,6 +395,7 @@ GLOBAL OPTIONS:
|
||||||
fmt.Sprintf("%d", hostGroup.ID),
|
fmt.Sprintf("%d", hostGroup.ID),
|
||||||
hostGroup.Name,
|
hostGroup.Name,
|
||||||
fmt.Sprintf("%d", len(hostGroup.Hosts)),
|
fmt.Sprintf("%d", len(hostGroup.Hosts)),
|
||||||
|
fmt.Sprintf("%d", len(hostGroup.ACLs)),
|
||||||
hostGroup.Comment,
|
hostGroup.Comment,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -732,11 +733,11 @@ GLOBAL OPTIONS:
|
||||||
Usage: "Lists user groups",
|
Usage: "Lists user groups",
|
||||||
Action: func(c *cli.Context) error {
|
Action: func(c *cli.Context) error {
|
||||||
var userGroups []UserGroup
|
var userGroups []UserGroup
|
||||||
if err := db.Preload("Users").Find(&userGroups).Error; err != nil {
|
if err := db.Preload("ACLs").Preload("Users").Find(&userGroups).Error; err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
table := tablewriter.NewWriter(s)
|
table := tablewriter.NewWriter(s)
|
||||||
table.SetHeader([]string{"ID", "Name", "Users", "Comment"})
|
table.SetHeader([]string{"ID", "Name", "Users", "ACLs", "Comment"})
|
||||||
table.SetBorder(false)
|
table.SetBorder(false)
|
||||||
table.SetCaption(true, fmt.Sprintf("Total: %d user groups.", len(userGroups)))
|
table.SetCaption(true, fmt.Sprintf("Total: %d user groups.", len(userGroups)))
|
||||||
for _, userGroup := range userGroups {
|
for _, userGroup := range userGroups {
|
||||||
|
@ -745,6 +746,7 @@ GLOBAL OPTIONS:
|
||||||
fmt.Sprintf("%d", userGroup.ID),
|
fmt.Sprintf("%d", userGroup.ID),
|
||||||
userGroup.Name,
|
userGroup.Name,
|
||||||
fmt.Sprintf("%d", len(userGroup.Users)),
|
fmt.Sprintf("%d", len(userGroup.Users)),
|
||||||
|
fmt.Sprintf("%d", len(userGroup.ACLs)),
|
||||||
userGroup.Comment,
|
userGroup.Comment,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue