list.go 631 B

123456789101112131415161718192021222324252627
  1. package network_user
  2. import (
  3. "github.com/gravitl/netmaker/cli/functions"
  4. "github.com/spf13/cobra"
  5. )
  6. var networkName string
  7. var networkuserListCmd = &cobra.Command{
  8. Use: "list",
  9. Args: cobra.NoArgs,
  10. Short: "List network users",
  11. Long: `List network users`,
  12. Run: func(cmd *cobra.Command, args []string) {
  13. if networkName != "" {
  14. functions.PrettyPrint(functions.GetNetworkUsers(networkName))
  15. } else {
  16. functions.PrettyPrint(functions.GetAllNetworkUsers())
  17. }
  18. },
  19. }
  20. func init() {
  21. networkuserListCmd.Flags().StringVar(&networkName, "network", "", "Name of the network")
  22. rootCmd.AddCommand(networkuserListCmd)
  23. }