forked from hwaf/hwaf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cmd_pmgr_get.go
64 lines (53 loc) · 1.36 KB
/
cmd_pmgr_get.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package main
import (
"fmt"
// "io"
// "io/ioutil"
// "os"
// "os/exec"
// "path"
// "path/filepath"
"strings"
"github.com/gonuts/commander"
"github.com/gonuts/flag"
)
func hwaf_make_cmd_pmgr_get() *commander.Command {
cmd := &commander.Command{
Run: hwaf_run_cmd_pmgr_get,
UsageLine: "get [options] <pkguri>",
Short: "download and install a package/project",
Long: `
get downloads and installs a package or project from a URI.
ex:
$ hwaf pmgr get cern.ch/mana-fwk/mana-latest
$ hwaf pmgr get -o /opt cern.ch/mana-fwk/mana-latest
`,
Flag: *flag.NewFlagSet("hwaf-pmgr-get", flag.ExitOnError),
}
cmd.Flag.Bool("v", false, "enable verbose output")
cmd.Flag.String("o", "", "directory where to install the package")
return cmd
}
func hwaf_run_cmd_pmgr_get(cmd *commander.Command, args []string) {
var err error
n := "hwaf-pmgr-" + cmd.Name()
verbose := cmd.Flag.Lookup("v").Value.Get().(bool)
pkguri := ""
switch len(args) {
case 1:
pkguri = args[0]
default:
err = fmt.Errorf("%s: you need to give a package URI to install", n)
handle_err(err)
}
pkguri = strings.Replace(pkguri, "http://", "", 1)
pkguri = strings.Replace(pkguri, "https://", "", 1)
if verbose {
fmt.Printf("%s: get [%s]...\n", n, pkguri)
}
//manifest_url := path.Join(pkguri, "MANIFEST")
if verbose {
fmt.Printf("%s: get [%s]... [ok]\n", n, pkguri)
}
}
// EOF