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

Function rewritePositionalPaths

internal/shell/shell.go:568–601  ·  view source on GitHub ↗
(args []string, currentPath string, limit int)

Source from the content-addressed store, hash-verified

566}
567
568func rewritePositionalPaths(args []string, currentPath string, limit int) []string {
569 rewritten := append([]string{}, args...)
570 stopFlags := false
571 rewrittenCount := 0
572
573 for i := 0; i < len(rewritten); i++ {
574 token := rewritten[i]
575 if stopFlags {
576 if limit < 0 || rewrittenCount < limit {
577 rewritten[i] = resolveShellPath(currentPath, token)
578 rewrittenCount++
579 }
580 continue
581 }
582
583 switch {
584 case token == "--":
585 stopFlags = true
586 case token == "--path" || token == "-p" || token == "--parent-id" || token == "-P" || token == "--output" || token == "-o" || token == "--input" || token == "-i" || token == "--count" || token == "-c" || token == "--rules":
587 if i+1 < len(rewritten) {
588 i++
589 }
590 case strings.HasPrefix(token, "-"):
591 default:
592 if limit >= 0 && rewrittenCount >= limit {
593 continue
594 }
595 rewritten[i] = resolveShellPath(currentPath, token)
596 rewrittenCount++
597 }
598 }
599
600 return rewritten
601}
602
603func changeDirectory(p *api.PikPak, currentPath string, args []string) (string, error) {
604 target := "/"

Callers 1

adaptShellArgsFunction · 0.85

Calls 1

resolveShellPathFunction · 0.85

Tested by

no test coverage detected