mirror of
https://github.com/tickstep/aliyunpan.git
synced 2025-02-02 21:27:15 +08:00
ls command support wildcard patterns
This commit is contained in:
parent
a15f704672
commit
b8aeead58c
@ -142,11 +142,32 @@ func RunLs(driveId, targetPath string, lsOptions *LsOptions,
|
|||||||
targetPath = text.Substr(targetPath, 0, len(targetPath)-1)
|
targetPath = text.Substr(targetPath, 0, len(targetPath)-1)
|
||||||
}
|
}
|
||||||
|
|
||||||
targetPathInfo, err := activeUser.PanClient().FileInfoByPath(driveId, targetPath)
|
//targetPathInfo, err := activeUser.PanClient().FileInfoByPath(driveId, targetPath)
|
||||||
|
//if err != nil {
|
||||||
|
// fmt.Println(err)
|
||||||
|
// return
|
||||||
|
//}
|
||||||
|
|
||||||
|
files, err := matchPathByShellPattern(driveId, targetPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
var targetPathInfo *aliyunpan.FileEntity
|
||||||
|
if len(files) == 1 {
|
||||||
|
targetPathInfo = files[0]
|
||||||
|
} else {
|
||||||
|
for _, f := range files {
|
||||||
|
if f.IsFolder() {
|
||||||
|
targetPathInfo = f
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if targetPathInfo == nil {
|
||||||
|
fmt.Println("目录路径不存在")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
fileList := aliyunpan.FileList{}
|
fileList := aliyunpan.FileList{}
|
||||||
fileListParam := &aliyunpan.FileListParam{}
|
fileListParam := &aliyunpan.FileListParam{}
|
||||||
@ -164,7 +185,7 @@ func RunLs(driveId, targetPath string, lsOptions *LsOptions,
|
|||||||
} else {
|
} else {
|
||||||
fileList = append(fileList, targetPathInfo)
|
fileList = append(fileList, targetPathInfo)
|
||||||
}
|
}
|
||||||
renderTable(opLs, lsOptions.Total, targetPath, fileList)
|
renderTable(opLs, lsOptions.Total, targetPathInfo.Path, fileList)
|
||||||
}
|
}
|
||||||
|
|
||||||
func renderTable(op int, isTotal bool, path string, files aliyunpan.FileList) {
|
func renderTable(op int, isTotal bool, path string, files aliyunpan.FileList) {
|
||||||
@ -218,12 +239,8 @@ func renderTable(op int, isTotal bool, path string, files aliyunpan.FileList) {
|
|||||||
fN, dN = files.Count()
|
fN, dN = files.Count()
|
||||||
tb.Append([]string{"", "总: " + converter.ConvertFileSize(files.TotalSize(), 2), "", fmt.Sprintf("文件总数: %d, 目录总数: %d", fN, dN)})
|
tb.Append([]string{"", "总: " + converter.ConvertFileSize(files.TotalSize(), 2), "", fmt.Sprintf("文件总数: %d, 目录总数: %d", fN, dN)})
|
||||||
}
|
}
|
||||||
|
fmt.Printf("\n当前目录: %s\n", path)
|
||||||
|
fmt.Printf("----\n")
|
||||||
tb.Render()
|
tb.Render()
|
||||||
|
|
||||||
if fN+dN >= 60 {
|
|
||||||
fmt.Printf("\n当前目录: %s\n", path)
|
|
||||||
}
|
|
||||||
|
|
||||||
fmt.Printf("----\n")
|
fmt.Printf("----\n")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user