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

Function changeDirectory

internal/shell/shell.go:603–619  ·  view source on GitHub ↗
(p *api.PikPak, currentPath string, args []string)

Source from the content-addressed store, hash-verified

601}
602
603func changeDirectory(p *api.PikPak, currentPath string, args []string) (string, error) {
604 target := "/"
605 if len(args) > 0 {
606 target = args[0]
607 }
608
609 targetPath := resolveShellPath(currentPath, target)
610 if targetPath == "/" {
611 return targetPath, nil
612 }
613
614 if _, err := p.GetPathFolderId(targetPath); err != nil {
615 return "", fmt.Errorf("cd: %s: no such directory", targetPath)
616 }
617
618 return targetPath, nil
619}
620
621func resolveShellPath(currentPath string, target string) string {
622 switch strings.TrimSpace(target) {

Callers 1

StartFunction · 0.85

Calls 2

resolveShellPathFunction · 0.85
GetPathFolderIdMethod · 0.65

Tested by

no test coverage detected