|
|
|
@ -16,36 +16,45 @@ package cmd
|
|
|
|
|
|
|
|
|
|
import ( |
|
|
|
|
"github.com/Unknwon/com" |
|
|
|
|
"github.com/codegangsta/cli" |
|
|
|
|
|
|
|
|
|
"github.com/gpmgo/gopm/doc" |
|
|
|
|
"github.com/gpmgo/gopm/log" |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
var CmdInstall = &Command{ |
|
|
|
|
UsageLine: "install", |
|
|
|
|
Short: "install according a gopmfile", |
|
|
|
|
Long: ` |
|
|
|
|
install just like go install |
|
|
|
|
`, |
|
|
|
|
var CmdInstall = cli.Command{ |
|
|
|
|
Name: "install", |
|
|
|
|
Usage: "link dependencies and go install", |
|
|
|
|
Description: `Command install links dependencies according to gopmfile, |
|
|
|
|
and execute 'go install' |
|
|
|
|
|
|
|
|
|
gopm install`, |
|
|
|
|
Action: runInstall, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func init() { |
|
|
|
|
CmdInstall.Run = runInstall |
|
|
|
|
CmdInstall.Flags = map[string]bool{} |
|
|
|
|
func runInstall(ctx *cli.Context) { |
|
|
|
|
if !com.IsFile(".gopmfile") { |
|
|
|
|
log.Fatal("Install", "No gopmfile exist in work directory") |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func printInstallPrompt(flag string) { |
|
|
|
|
gf := doc.NewGopmfile(".") |
|
|
|
|
target := gf.MustValue("target", "path") |
|
|
|
|
if len(target) == 0 { |
|
|
|
|
log.Fatal("Install", "Cannot find target in gopmfile") |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func runInstall(cmd *Command, args []string) { |
|
|
|
|
//genNewGoPath()
|
|
|
|
|
genNewGoPath(ctx) |
|
|
|
|
|
|
|
|
|
com.ColorLog("[INFO] installing ...\n") |
|
|
|
|
log.Trace("Installing...") |
|
|
|
|
|
|
|
|
|
cmds := []string{"go", "install"} |
|
|
|
|
cmds = append(cmds, args...) |
|
|
|
|
err := execCmd(newGoPath, newCurPath, cmds...) |
|
|
|
|
cmdArgs := []string{"go", "install"} |
|
|
|
|
cmdArgs = append(cmdArgs, ctx.Args()...) |
|
|
|
|
cmdArgs = append(cmdArgs, target) |
|
|
|
|
err := execCmd(newGoPath, newCurPath, cmdArgs...) |
|
|
|
|
if err != nil { |
|
|
|
|
com.ColorLog("[ERRO] install failed: %v\n", err) |
|
|
|
|
return |
|
|
|
|
log.Error("Install", "Fail to install program") |
|
|
|
|
log.Fatal("", err.Error()) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
com.ColorLog("[SUCC] install successfully!\n") |
|
|
|
|
log.Success("SUCC", "Install", "Command execute successfully!") |
|
|
|
|
} |
|
|
|
|