github.com/engineyard/workflow-cli@v2.21.6+incompatible/parser/routing.go (about) 1 package parser 2 3 import ( 4 "github.com/teamhephy/workflow-cli/cmd" 5 docopt "github.com/docopt/docopt-go" 6 ) 7 8 // Routing displays all relevant commands for `deis routing`. 9 func Routing(argv []string, cmdr cmd.Commander) error { 10 usage := ` 11 Valid commands for routing: 12 13 routing:info view routability of an application 14 routing:enable enable routing for an app 15 routing:disable disable routing for an app 16 17 Use 'deis help [command]' to learn more. 18 ` 19 20 switch argv[0] { 21 case "routing:info": 22 return routingInfo(argv, cmdr) 23 case "routing:enable": 24 return routingEnable(argv, cmdr) 25 case "routing:disable": 26 return routingDisable(argv, cmdr) 27 default: 28 if printHelp(argv, usage) { 29 return nil 30 } 31 32 if argv[0] == "routing" { 33 argv[0] = "routing:info" 34 return routingInfo(argv, cmdr) 35 } 36 37 PrintUsage(cmdr) 38 return nil 39 } 40 } 41 42 func routingInfo(argv []string, cmdr cmd.Commander) error { 43 usage := ` 44 Prints info about the current application's routability. 45 46 Usage: deis routing:info [options] 47 48 Options: 49 -a --app=<app> 50 the uniquely identifiable name for the application. 51 ` 52 53 args, err := docopt.Parse(usage, argv, true, "", false, true) 54 if err != nil { 55 return err 56 } 57 58 return cmdr.RoutingInfo(safeGetValue(args, "--app")) 59 } 60 61 func routingEnable(argv []string, cmdr cmd.Commander) error { 62 usage := ` 63 Enables routability for an app. 64 65 Usage: deis routing:enable [options] 66 67 Options: 68 -a --app=<app> 69 the uniquely identifiable name of the application. 70 ` 71 72 args, err := docopt.Parse(usage, argv, true, "", false, true) 73 if err != nil { 74 return err 75 } 76 77 return cmdr.RoutingEnable(safeGetValue(args, "--app")) 78 } 79 80 func routingDisable(argv []string, cmdr cmd.Commander) error { 81 usage := ` 82 Disables routability for an app. 83 84 Usage: deis routing:disable [options] 85 86 Options: 87 -a --app=<app> 88 the uniquely identifiable name of the application. 89 ` 90 91 args, err := docopt.Parse(usage, argv, true, "", false, true) 92 93 if err != nil { 94 return err 95 } 96 97 return cmdr.RoutingDisable(safeGetValue(args, "--app")) 98 }