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

Method RunCommand

dev/devcam/mount.go:85–124  ·  view source on GitHub ↗
(args []string)

Source from the content-addressed store, hash-verified

83}
84
85func (c *mountCmd) RunCommand(args []string) error {
86 err := c.checkFlags(args)
87 if err != nil {
88 return cmdmain.UsageError(fmt.Sprint(err))
89 }
90 if !*noBuild {
91 if err := build(filepath.Join("cmd", "pk-mount")); err != nil {
92 return fmt.Errorf("Could not build pk-mount: %v", err)
93 }
94 }
95 c.env.SetCamdevVars(c.altkey)
96 // wipeCacheDir needs to be called after SetCamdevVars, because that is
97 // where CAMLI_CACHE_DIR is defined.
98 if *wipeCache {
99 c.env.wipeCacheDir()
100 }
101
102 tryUnmount(mountpoint)
103 if err := os.Mkdir(mountpoint, 0700); err != nil && !os.IsExist(err) {
104 return fmt.Errorf("Could not make mount point: %v", err)
105 }
106
107 blobserver := "http://localhost:" + c.port + c.path
108 if c.tls {
109 blobserver = strings.Replace(blobserver, "http://", "https://", 1)
110 }
111
112 cmdBin, err := osutil.LookPathGopath("pk-mount")
113 if err != nil {
114 return err
115 }
116 cmdArgs := []string{
117 "-debug=" + strconv.FormatBool(c.debug),
118 "-server=" + blobserver,
119 }
120 cmdArgs = append(cmdArgs, args...)
121 cmdArgs = append(cmdArgs, mountpoint)
122 fmt.Printf("pk-mount running with mountpoint %v. Press 'q' <enter> or ctrl-c to shut down.\n", mountpoint)
123 return runExec(cmdBin, cmdArgs, c.env)
124}
125
126func (c *mountCmd) checkFlags(args []string) error {
127 if _, err := strconv.ParseInt(c.port, 0, 0); err != nil {

Callers

nothing calls this directly

Calls 10

checkFlagsMethod · 0.95
UsageErrorTypeAlias · 0.92
LookPathGopathFunction · 0.92
tryUnmountFunction · 0.85
SetCamdevVarsMethod · 0.80
wipeCacheDirMethod · 0.80
PrintfMethod · 0.80
buildFunction · 0.70
runExecFunction · 0.70
MkdirMethod · 0.45

Tested by

no test coverage detected