|
|
|
@ -37,6 +37,7 @@ func init() {
|
|
|
|
|
"-d": false, |
|
|
|
|
"-u": false, // Flag for 'go get'.
|
|
|
|
|
"-e": false, |
|
|
|
|
"-b": false, |
|
|
|
|
"-s": false, |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -51,8 +52,6 @@ func printInstallPrompt(flag string) {
|
|
|
|
|
fmt.Printf(fmt.Sprintf("%s\n", PromptMsg["DownloadOnly"])) |
|
|
|
|
case "-e": |
|
|
|
|
fmt.Printf(fmt.Sprintf("%s\n", PromptMsg["DownloadExDeps"])) |
|
|
|
|
case "-s": |
|
|
|
|
fmt.Printf(fmt.Sprintf("%s\n", PromptMsg["DownloadFromSrcs"])) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -123,12 +122,43 @@ func runInstall(cmd *Command, args []string) {
|
|
|
|
|
installGOPATH = utils.GetBestMatchGOPATH(AppPath) |
|
|
|
|
utils.ColorPrint(fmt.Sprintf(fmt.Sprintf("%s\n", PromptMsg["DownloadPath"]), installGOPATH)) |
|
|
|
|
|
|
|
|
|
// Generate temporary nodes.
|
|
|
|
|
nodes := make([]*node.Node, len(args)) |
|
|
|
|
for i := range nodes { |
|
|
|
|
nodes[i] = new(node.Node) |
|
|
|
|
nodes[i].ImportPath = args[i] |
|
|
|
|
var nodes []*node.Node |
|
|
|
|
// Check if it is a bundle or snapshot.
|
|
|
|
|
switch { |
|
|
|
|
case CmdInstall.Flags["-b"]: |
|
|
|
|
bundle := args[0] |
|
|
|
|
// Check local bundles.
|
|
|
|
|
nodes = checkLocalBundles(bundle) |
|
|
|
|
if len(nodes) > 0 { |
|
|
|
|
// Check with users if continue.
|
|
|
|
|
utils.ColorPrint(fmt.Sprintf(fmt.Sprintf("%s\n", PromptMsg["BundleInfo"]), bundle)) |
|
|
|
|
for _, n := range nodes { |
|
|
|
|
fmt.Printf("[%s] -> %s: %s.\n", n.ImportPath, n.Type, n.Value) |
|
|
|
|
} |
|
|
|
|
fmt.Printf(fmt.Sprintf("%s\n", PromptMsg["ContinueDownload"])) |
|
|
|
|
var option string |
|
|
|
|
fmt.Fscan(os.Stdin, &option) |
|
|
|
|
if strings.ToLower(option) != "y" { |
|
|
|
|
os.Exit(0) |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
// Check from server.
|
|
|
|
|
// TODO: api.GetBundleInfo()
|
|
|
|
|
fmt.Println("Unable to find bundle, and we cannot check with server right now.") |
|
|
|
|
} |
|
|
|
|
case CmdInstall.Flags["-s"]: |
|
|
|
|
fmt.Println("gopm has not supported snapshot yet.") |
|
|
|
|
// TODO: api.GetSnapshotInfo()
|
|
|
|
|
default: |
|
|
|
|
// Generate temporary nodes.
|
|
|
|
|
nodes = make([]*node.Node, len(args)) |
|
|
|
|
for i := range nodes { |
|
|
|
|
nodes[i] = new(node.Node) |
|
|
|
|
nodes[i].ImportPath = args[i] |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Download packages.
|
|
|
|
|
downloadPackages(nodes) |
|
|
|
|
|
|
|
|
@ -197,33 +227,8 @@ func checkLocalBundles(bundle string) (nodes []*node.Node) {
|
|
|
|
|
func downloadPackages(nodes []*node.Node) { |
|
|
|
|
// Check all packages, they may be bundles, snapshots or raw packages path.
|
|
|
|
|
for _, n := range nodes { |
|
|
|
|
// Check if it is a bundle or snapshot.
|
|
|
|
|
switch { |
|
|
|
|
case strings.HasSuffix(n.ImportPath, ".b"): |
|
|
|
|
l := len(n.ImportPath) |
|
|
|
|
// Check local bundles.
|
|
|
|
|
bnodes := checkLocalBundles(n.ImportPath[:l-2]) |
|
|
|
|
if len(bnodes) > 0 { |
|
|
|
|
// Check with users if continue.
|
|
|
|
|
utils.ColorPrint(fmt.Sprintf(fmt.Sprintf("%s\n", PromptMsg["BundleInfo"]), n.ImportPath[:l-2])) |
|
|
|
|
for _, bn := range bnodes { |
|
|
|
|
fmt.Printf("[%s] -> %s: %s.\n", bn.ImportPath, bn.Type, bn.Value) |
|
|
|
|
} |
|
|
|
|
fmt.Printf(fmt.Sprintf("%s\n", PromptMsg["ContinueDownload"])) |
|
|
|
|
var option string |
|
|
|
|
fmt.Fscan(os.Stdin, &option) |
|
|
|
|
if strings.ToLower(option) != "y" { |
|
|
|
|
os.Exit(0) |
|
|
|
|
} |
|
|
|
|
downloadPackages(bnodes) |
|
|
|
|
} else { |
|
|
|
|
// Check from server.
|
|
|
|
|
// TODO: api.GetBundleInfo()
|
|
|
|
|
fmt.Println("Unable to find bundle, and we cannot check with server right now.") |
|
|
|
|
} |
|
|
|
|
case strings.HasSuffix(n.ImportPath, ".s"): |
|
|
|
|
// TODO: api.GetSnapshotInfo()
|
|
|
|
|
case utils.IsValidRemotePath(n.ImportPath): |
|
|
|
|
// Check if it is a valid remote path.
|
|
|
|
|
if utils.IsValidRemotePath(n.ImportPath) { |
|
|
|
|
if !downloadCache[n.ImportPath] { |
|
|
|
|
// Download package.
|
|
|
|
|
nod, imports := downloadPackage(n) |
|
|
|
@ -246,7 +251,7 @@ func downloadPackages(nodes []*node.Node) {
|
|
|
|
|
} else { |
|
|
|
|
fmt.Printf(fmt.Sprintf("%s\n", PromptMsg["SkipDownloaded"]), n.ImportPath) |
|
|
|
|
} |
|
|
|
|
default: |
|
|
|
|
} else { |
|
|
|
|
// Invalid import path.
|
|
|
|
|
fmt.Printf(fmt.Sprintf("%s\n", PromptMsg["SkipInvalidPath"]), n.ImportPath) |
|
|
|
|
} |
|
|
|
|