MCPcopy Create free account
hub / github.com/52funny/pikpakcli / buildOpenCommand

Function buildOpenCommand

internal/shell/open.go:195–219  ·  view source on GitHub ↗
(goos string, cfg conf.OpenConfig, path string, category string)

Source from the content-addressed store, hash-verified

193}
194
195func buildOpenCommand(goos string, cfg conf.OpenConfig, path string, category string) (string, []string, error) {
196 command := commandForCategory(cfg, category)
197 if len(command) == 0 {
198 command = defaultOpenCommand(goos, category)
199 }
200 if len(command) == 0 {
201 return "", nil, fmt.Errorf("unsupported platform: %s", goos)
202 }
203
204 resolved := make([]string, 0, len(command)+1)
205 hasPlaceholder := false
206 for _, item := range command {
207 if item == "{path}" {
208 resolved = append(resolved, path)
209 hasPlaceholder = true
210 continue
211 }
212 resolved = append(resolved, item)
213 }
214 if !hasPlaceholder {
215 resolved = append(resolved, path)
216 }
217
218 return resolved[0], resolved[1:], nil
219}
220
221func commandForCategory(cfg conf.OpenConfig, category string) []string {
222 switch category {

Callers 2

openWithLocalAppFunction · 0.85
TestBuildOpenCommandFunction · 0.85

Calls 2

commandForCategoryFunction · 0.85
defaultOpenCommandFunction · 0.85

Tested by 1

TestBuildOpenCommandFunction · 0.68