github.com/engineyard/workflow-cli@v2.21.6+incompatible/parser/tls.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 // TLS routes tls commands to their specific function. 9 func TLS(argv []string, cmdr cmd.Commander) error { 10 usage := ` 11 Valid commands for tls: 12 13 tls:info view info about an application's TLS settings 14 tls:enable enables the router to enforce https-only requests to an application 15 tls:disable disables the router to enforce https-only requests to an application 16 17 Use 'deis help [command]' to learn more. 18 ` 19 20 switch argv[0] { 21 case "tls:info": 22 return tlsInfo(argv, cmdr) 23 case "tls:enable": 24 return tlsEnable(argv, cmdr) 25 case "tls:disable": 26 return tlsDisable(argv, cmdr) 27 default: 28 if printHelp(argv, usage) { 29 return nil 30 } 31 32 if argv[0] == "tls" { 33 argv[0] = "tls:info" 34 return tlsInfo(argv, cmdr) 35 } 36 37 PrintUsage(cmdr) 38 return nil 39 } 40 } 41 42 func tlsInfo(argv []string, cmdr cmd.Commander) error { 43 usage := ` 44 Prints info about the current application's TLS settings. 45 46 Usage: deis tls: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 55 if err != nil { 56 return err 57 } 58 59 return cmdr.TLSInfo(safeGetValue(args, "--app")) 60 } 61 62 func tlsEnable(argv []string, cmdr cmd.Commander) error { 63 usage := ` 64 Enable the router to enforce https-only requests to the current application. 65 66 Usage: deis tls:enable [options] 67 68 Options: 69 -a --app=<app> 70 the uniquely identifiable name for the application. 71 ` 72 73 args, err := docopt.Parse(usage, argv, true, "", false, true) 74 75 if err != nil { 76 return err 77 } 78 79 return cmdr.TLSEnable(safeGetValue(args, "--app")) 80 } 81 82 func tlsDisable(argv []string, cmdr cmd.Commander) error { 83 usage := ` 84 Disable the router from enforcing https-only requests to the current application. 85 86 Usage: deis tls:disable [options] 87 88 Options: 89 -a --app=<app> 90 the uniquely identifiable name for the application. 91 ` 92 93 args, err := docopt.Parse(usage, argv, true, "", false, true) 94 95 if err != nil { 96 return err 97 } 98 99 return cmdr.TLSDisable(safeGetValue(args, "--app")) 100 }