(args []string, currentPath string, limit int)
| 566 | } |
| 567 | |
| 568 | func 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 | |
| 603 | func changeDirectory(p *api.PikPak, currentPath string, args []string) (string, error) { |
| 604 | target := "/" |
no test coverage detected