forked from Telmate/proxmox-api-go
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add toggle for user list command
Added a toggle to make the returning of the groups optional, as not all internal functions need te group information
- Loading branch information
1 parent
b41fb57
commit daf13c5
Showing
5 changed files
with
39 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,35 @@ | ||
package list | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
|
||
"github.com/Telmate/proxmox-api-go/cli" | ||
"github.com/Telmate/proxmox-api-go/proxmox" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var list_usersCmd = &cobra.Command{ | ||
Use: "users", | ||
Short: "Prints a list of Users in raw json format", | ||
Args: cobra.NoArgs, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
listRaw("Users") | ||
RunE: func(cmd *cobra.Command, args []string) (err error) { | ||
c := cli.NewClient() | ||
groups, _ := cmd.Flags().GetBool("groups") | ||
users, err := proxmox.ListUsers(c, groups) | ||
if err != nil { | ||
return | ||
} | ||
output, err := json.Marshal(users) | ||
if err != nil { | ||
return | ||
} | ||
fmt.Fprintln(listCmd.OutOrStdout(), string(output)) | ||
return | ||
}, | ||
} | ||
|
||
func init() { | ||
listCmd.AddCommand(list_usersCmd) | ||
list_usersCmd.PersistentFlags().Bool("groups", false, "Result will include group membership") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters