MCPcopy
hub / github.com/perkeep/perkeep / RunCommand

Method RunCommand

dev/devcam/get.go:72–105  ·  view source on GitHub ↗
(args []string)

Source from the content-addressed store, hash-verified

70}
71
72func (c *getCmd) RunCommand(args []string) error {
73 err := c.checkFlags(args)
74 if err != nil {
75 return cmdmain.UsageError(fmt.Sprint(err))
76 }
77 if !*noBuild {
78 if err := build(filepath.Join("cmd", "pk-get")); err != nil {
79 return fmt.Errorf("Could not build pk-get: %v", err)
80 }
81 }
82 c.env.SetCamdevVars(c.altkey)
83 // wipeCacheDir needs to be called after SetCamdevVars, because that is
84 // where CAMLI_CACHE_DIR is defined.
85 if *wipeCache {
86 c.env.wipeCacheDir()
87 }
88
89 cmdBin, err := osutil.LookPathGopath("pk-get")
90 if err != nil {
91 return err
92 }
93 cmdArgs := []string{
94 "-verbose=" + strconv.FormatBool(*cmdmain.FlagVerbose || !quiet),
95 }
96 if !isSharedMode(args) {
97 blobserver := "http://localhost:" + c.port + c.path
98 if c.tls {
99 blobserver = strings.Replace(blobserver, "http://", "https://", 1)
100 }
101 cmdArgs = append(cmdArgs, "-server="+blobserver)
102 }
103 cmdArgs = append(cmdArgs, args...)
104 return runExec(cmdBin, cmdArgs, c.env)
105}
106
107func (c *getCmd) checkFlags(args []string) error {
108 if _, err := strconv.ParseInt(c.port, 0, 0); err != nil {

Callers

nothing calls this directly

Calls 8

checkFlagsMethod · 0.95
UsageErrorTypeAlias · 0.92
LookPathGopathFunction · 0.92
isSharedModeFunction · 0.85
SetCamdevVarsMethod · 0.80
wipeCacheDirMethod · 0.80
buildFunction · 0.70
runExecFunction · 0.70

Tested by

no test coverage detected