weed shell: add fs.cd, fs.pwd to change to a directory and print current directory

This commit is contained in:
Chris Lu
2019-04-03 00:20:00 -07:00
parent 20dcb44077
commit 715a38da1e
6 changed files with 189 additions and 25 deletions

View File

@@ -44,17 +44,29 @@ func (c *commandFsLs) Do(args []string, commandEnv *commandEnv, writer io.Writer
}
}
filerServer, filerPort, path, err := parseFilerUrl(args[len(args)-1])
input := ""
if len(args) > 0 {
input = args[len(args)-1]
if strings.HasPrefix(input, "-") {
input = ""
}
}
filerServer, filerPort, path, err := commandEnv.parseUrl(input)
if err != nil {
return err
}
if input == "" && !strings.HasSuffix(path, "/") {
path = path + "/"
}
dir, name := filer2.FullPath(path).DirAndName()
// println("path", path, "dir", dir, "name", name)
if strings.HasSuffix(path, "/") {
if path == "/" {
dir, name = "/", ""
} else {
dir, name = path[0:len(path)-1], ""
dir, name = path[0 : len(path)-1], ""
}
}