You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

61 lines
1.6 KiB

11 years ago
// Copyright 2013 gopm authors.
//
// Licensed under the Apache License, Version 2.0 (the "License"): you may
// not use this file except in compliance with the License. You may obtain
// a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations
// under the License.
package cmd
import (
"github.com/Unknwon/com"
"github.com/codegangsta/cli"
"github.com/gpmgo/gopm/doc"
"github.com/gpmgo/gopm/log"
11 years ago
)
var CmdInstall = cli.Command{
Name: "install",
Usage: "link dependencies and go install",
Description: `Command install links dependencies according to gopmfile,
and execute 'go install'
11 years ago
gopm install`,
Action: runInstall,
11 years ago
}
func runInstall(ctx *cli.Context) {
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")
}
11 years ago
genNewGoPath(ctx)
11 years ago
log.Trace("Installing...")
11 years ago
cmdArgs := []string{"go", "install"}
cmdArgs = append(cmdArgs, ctx.Args()...)
cmdArgs = append(cmdArgs, target)
err := execCmd(newGoPath, newCurPath, cmdArgs...)
11 years ago
if err != nil {
log.Error("Install", "Fail to install program")
log.Fatal("", err.Error())
11 years ago
}
log.Success("SUCC", "Install", "Command execute successfully!")
11 years ago
}