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

Function expandShellGlobs

internal/shell/shell.go:646–679  ·  view source on GitHub ↗
(rootCmd *cobra.Command, currentPath string, source fileStatProvider, args []string)

Source from the content-addressed store, hash-verified

644}
645
646func 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
681func expandDownloadGlobs(args []string, currentPath string, source fileStatProvider) ([]string, error) {
682 return rewriteDownloadLikeArgs(args, currentPath, source)

Callers 4

StartFunction · 0.85

Calls 5

resolveCommandFunction · 0.85
canonicalCommandKeyFunction · 0.85
expandDownloadGlobsFunction · 0.85
expandDeleteGlobsFunction · 0.85
expandUploadGlobsFunction · 0.85

Tested by 3