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

Method RunCommand

dev/devcam/put.go:70–102  ·  view source on GitHub ↗
(args []string)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected