github.com/naphatkrit/deis@v1.12.3/client/parser/users.go (about) 1 package parser 2 3 import ( 4 "github.com/deis/deis/client/cmd" 5 docopt "github.com/docopt/docopt-go" 6 ) 7 8 // Users routes user commands to the specific function. 9 func Users(argv []string) error { 10 usage := ` 11 Valid commands for users: 12 13 users:list list all registered users 14 15 Use 'deis help [command]' to learn more. 16 ` 17 18 switch argv[0] { 19 case "users:list": 20 return usersList(argv) 21 default: 22 if printHelp(argv, usage) { 23 return nil 24 } 25 26 if argv[0] == "users" { 27 argv[0] = "users:list" 28 return usersList(argv) 29 } 30 31 PrintUsage() 32 return nil 33 } 34 } 35 36 func usersList(argv []string) error { 37 usage := ` 38 Lists all registered users. 39 Requires admin privilages. 40 41 Usage: deis users:list [options] 42 43 Options: 44 -l --limit=<num> 45 the maximum number of results to display, defaults to config setting 46 ` 47 48 args, err := docopt.Parse(usage, argv, true, "", false, true) 49 50 if err != nil { 51 return err 52 } 53 54 results, err := responseLimit(safeGetValue(args, "--limit")) 55 56 if err != nil { 57 return err 58 } 59 60 return cmd.UsersList(results) 61 }