github.com/naphatkrit/deis@v1.12.3/client/parser/builds.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 // Builds routes build commands to their specific function. 9 func Builds(argv []string) error { 10 usage := ` 11 Valid commands for builds: 12 13 builds:list list build history for an application 14 builds:create imports an image and deploys as a new release 15 16 Use 'deis help [command]' to learn more. 17 ` 18 19 switch argv[0] { 20 case "builds:list": 21 return buildsList(argv) 22 case "builds:create": 23 return buildsCreate(argv) 24 default: 25 if printHelp(argv, usage) { 26 return nil 27 } 28 29 if argv[0] == "builds" { 30 argv[0] = "builds:list" 31 return buildsList(argv) 32 } 33 34 PrintUsage() 35 return nil 36 } 37 } 38 39 func buildsList(argv []string) error { 40 usage := ` 41 Lists build history for an application. 42 43 Usage: deis builds:list [options] 44 45 Options: 46 -a --app=<app> 47 the uniquely identifiable name for the application. 48 -l --limit=<num> 49 the maximum number of results to display, defaults to config setting 50 ` 51 52 args, err := docopt.Parse(usage, argv, true, "", false, true) 53 54 if err != nil { 55 return err 56 } 57 58 results, err := responseLimit(safeGetValue(args, "--limit")) 59 60 if err != nil { 61 return err 62 } 63 64 return cmd.BuildsList(safeGetValue(args, "--app"), results) 65 } 66 67 func buildsCreate(argv []string) error { 68 usage := ` 69 Creates a new build of an application. Imports an <image> and deploys it to Deis 70 as a new release. If a Procfile is present in the current directory, it will be used 71 as the default process types for this application. 72 73 Usage: deis builds:create <image> [options] 74 75 Arguments: 76 <image> 77 A fully-qualified docker image, either from Docker Hub (e.g. deis/example-go:latest) 78 or from an in-house registry (e.g. myregistry.example.com:5000/example-go:latest). 79 This image must include the tag. 80 81 Options: 82 -a --app=<app> 83 The uniquely identifiable name for the application. 84 -p --procfile=<procfile> 85 A YAML string used to supply a Procfile to the application. 86 ` 87 88 args, err := docopt.Parse(usage, argv, true, "", false, true) 89 90 if err != nil { 91 return err 92 } 93 94 app := safeGetValue(args, "--app") 95 image := safeGetValue(args, "<image>") 96 procfile := safeGetValue(args, "--procfile") 97 98 return cmd.BuildsCreate(app, image, procfile) 99 }