| 644 | } |
| 645 | |
| 646 | func expandShellGlobs(rootCmd *cobra.Command, currentPath string, source fileStatProvider, args []string) ([]string, error) { |
| 647 | if len(args) == 0 { |
| 648 | return args, nil |
| 649 | } |
| 650 | |
| 651 | cmd, consumed := resolveCommand(rootCmd, args) |
| 652 | if consumed == 0 { |
| 653 | return args, nil |
| 654 | } |
| 655 | |
| 656 | commandKey := canonicalCommandKey(rootCmd, cmd) |
| 657 | rest := append([]string{}, args[consumed:]...) |
| 658 | |
| 659 | var ( |
| 660 | expanded []string |
| 661 | err error |
| 662 | ) |
| 663 | |
| 664 | switch commandKey { |
| 665 | case "download": |
| 666 | expanded, err = expandDownloadGlobs(rest, currentPath, source) |
| 667 | case "delete": |
| 668 | expanded, err = expandDeleteGlobs(rest, currentPath, source) |
| 669 | case "upload": |
| 670 | expanded, err = expandUploadGlobs(rest) |
| 671 | default: |
| 672 | return args, nil |
| 673 | } |
| 674 | if err != nil { |
| 675 | return nil, err |
| 676 | } |
| 677 | |
| 678 | return append(append([]string{}, args[:consumed]...), expanded...), nil |
| 679 | } |
| 680 | |
| 681 | func expandDownloadGlobs(args []string, currentPath string, source fileStatProvider) ([]string, error) { |
| 682 | return rewriteDownloadLikeArgs(args, currentPath, source) |