From 88629917a0277ba0e59122fff03b1529774af015 Mon Sep 17 00:00:00 2001 From: Unknown Date: Mon, 11 Nov 2013 02:17:45 -0500 Subject: [PATCH] Improve install --- cmd/install.go | 36 +++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/cmd/install.go b/cmd/install.go index 8080d1b4c..4caba7b06 100644 --- a/cmd/install.go +++ b/cmd/install.go @@ -28,19 +28,34 @@ var CmdInstall = cli.Command{ Description: `Command install links dependencies according to gopmfile, and execute 'go install' -gopm install`, +gopm install +gopm install + +If no argument is supplied, then gopmfile must be present`, Action: runInstall, + Flags: []cli.Flag{ + cli.BoolFlag{"verbose", "show process details"}, + }, } func runInstall(ctx *cli.Context) { - if !com.IsFile(".gopmfile") { - log.Fatal("Install", "No gopmfile exist in work directory") - } + var target string + + switch len(ctx.Args()) { + case 0: + if !com.IsFile(".gopmfile") { + log.Fatal("Install", "No gopmfile exist in work directory") + } - gf := doc.NewGopmfile(".") - target := gf.MustValue("target", "path") - if len(target) == 0 { - log.Fatal("Install", "Cannot find target in gopmfile") + gf := doc.NewGopmfile(".") + target = gf.MustValue("target", "path") + if len(target) == 0 { + log.Fatal("Install", "Cannot find target in gopmfile") + } + case 1: + target = ctx.Args()[0] + default: + log.Fatal("Install", "Too many arguments") } genNewGoPath(ctx) @@ -48,7 +63,10 @@ func runInstall(ctx *cli.Context) { log.Trace("Installing...") cmdArgs := []string{"go", "install"} - cmdArgs = append(cmdArgs, ctx.Args()...) + + if ctx.Bool("verbose") { + cmdArgs = append(cmdArgs, "-v") + } cmdArgs = append(cmdArgs, target) err := execCmd(newGoPath, newCurPath, cmdArgs...) if err != nil {