mirror of
https://github.com/tickstep/aliyunpan.git
synced 2025-02-02 21:27:15 +08:00
change index number of table starts as one
This commit is contained in:
parent
3e1b87f5f2
commit
15bef9fcc3
@ -240,7 +240,7 @@ func RunAlbumList() {
|
|||||||
tb.SetHeader([]string{"#", "ALBUM_ID", "名称", "文件数量", "创建日期", "修改日期"})
|
tb.SetHeader([]string{"#", "ALBUM_ID", "名称", "文件数量", "创建日期", "修改日期"})
|
||||||
tb.SetColumnAlignment([]int{tablewriter.ALIGN_DEFAULT, tablewriter.ALIGN_DEFAULT, tablewriter.ALIGN_LEFT, tablewriter.ALIGN_CENTER, tablewriter.ALIGN_DEFAULT, tablewriter.ALIGN_DEFAULT})
|
tb.SetColumnAlignment([]int{tablewriter.ALIGN_DEFAULT, tablewriter.ALIGN_DEFAULT, tablewriter.ALIGN_LEFT, tablewriter.ALIGN_CENTER, tablewriter.ALIGN_DEFAULT, tablewriter.ALIGN_DEFAULT})
|
||||||
for k, record := range records {
|
for k, record := range records {
|
||||||
tb.Append([]string{strconv.Itoa(k), record.AlbumId, record.Name, strconv.Itoa(record.FileCount),
|
tb.Append([]string{strconv.Itoa(k + 1), record.AlbumId, record.Name, strconv.Itoa(record.FileCount),
|
||||||
record.CreatedAtStr(), record.UpdatedAtStr()})
|
record.CreatedAtStr(), record.UpdatedAtStr()})
|
||||||
}
|
}
|
||||||
tb.Render()
|
tb.Render()
|
||||||
|
@ -49,10 +49,10 @@ func CmdDrive() cli.Command {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func RunSwitchDriveList(targetDriveId string) {
|
func RunSwitchDriveList(targetDriveId string) {
|
||||||
currentDriveId := config.Config.ActiveUser().ActiveDriveId
|
currentDriveId := config.Config.ActiveUser().ActiveDriveId
|
||||||
var activeDriveInfo *config.DriveInfo = nil
|
var activeDriveInfo *config.DriveInfo = nil
|
||||||
driveList,renderStr := getDriveOptionList()
|
driveList, renderStr := getDriveOptionList()
|
||||||
|
|
||||||
if driveList == nil || len(driveList) == 0 {
|
if driveList == nil || len(driveList) == 0 {
|
||||||
fmt.Println("切换网盘失败")
|
fmt.Println("切换网盘失败")
|
||||||
@ -71,15 +71,15 @@ func RunSwitchDriveList(targetDriveId string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if n, err := strconv.Atoi(index); err == nil && n >= 0 && n < len(driveList) {
|
if n, err1 := strconv.Atoi(index); err1 == nil && (n-1) >= 0 && (n-1) < len(driveList) {
|
||||||
activeDriveInfo = driveList[n]
|
activeDriveInfo = driveList[n-1]
|
||||||
} else {
|
} else {
|
||||||
fmt.Printf("切换网盘失败, 请检查 # 值是否正确\n")
|
fmt.Printf("切换网盘失败, 请检查 # 值是否正确\n")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// 直接切换
|
// 直接切换
|
||||||
for _,driveInfo := range driveList {
|
for _, driveInfo := range driveList {
|
||||||
if driveInfo.DriveId == targetDriveId {
|
if driveInfo.DriveId == targetDriveId {
|
||||||
activeDriveInfo = driveInfo
|
activeDriveInfo = driveInfo
|
||||||
break
|
break
|
||||||
@ -121,7 +121,7 @@ func getDriveOptionList() (config.DriveInfoList, string) {
|
|||||||
tb.SetHeader([]string{"#", "drive_id", "网盘名称"})
|
tb.SetHeader([]string{"#", "drive_id", "网盘名称"})
|
||||||
|
|
||||||
for k, info := range driveList {
|
for k, info := range driveList {
|
||||||
tb.Append([]string{strconv.Itoa(k), info.DriveId, info.DriveName})
|
tb.Append([]string{strconv.Itoa(k + 1), info.DriveId, info.DriveName})
|
||||||
}
|
}
|
||||||
tb.Render()
|
tb.Render()
|
||||||
return driveList, builder.String()
|
return driveList, builder.String()
|
||||||
|
@ -186,15 +186,15 @@ func renderTable(op int, isTotal bool, path string, files aliyunpan.FileList) {
|
|||||||
tb.SetColumnAlignment([]int{tablewriter.ALIGN_DEFAULT, tablewriter.ALIGN_RIGHT, tablewriter.ALIGN_LEFT, tablewriter.ALIGN_LEFT, tablewriter.ALIGN_LEFT, tablewriter.ALIGN_LEFT, tablewriter.ALIGN_LEFT, tablewriter.ALIGN_LEFT})
|
tb.SetColumnAlignment([]int{tablewriter.ALIGN_DEFAULT, tablewriter.ALIGN_RIGHT, tablewriter.ALIGN_LEFT, tablewriter.ALIGN_LEFT, tablewriter.ALIGN_LEFT, tablewriter.ALIGN_LEFT, tablewriter.ALIGN_LEFT, tablewriter.ALIGN_LEFT})
|
||||||
for k, file := range files {
|
for k, file := range files {
|
||||||
if file.IsFolder() {
|
if file.IsFolder() {
|
||||||
tb.Append([]string{strconv.Itoa(k), file.FileId, "-", "-", "-", file.CreatedAt, file.UpdatedAt, file.FileName + aliyunpan.PathSeparator})
|
tb.Append([]string{strconv.Itoa(k + 1), file.FileId, "-", "-", "-", file.CreatedAt, file.UpdatedAt, file.FileName + aliyunpan.PathSeparator})
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
switch op {
|
switch op {
|
||||||
case opLs:
|
case opLs:
|
||||||
tb.Append([]string{strconv.Itoa(k), file.FileId, converter.ConvertFileSize(file.FileSize, 2), file.ContentHash, strconv.FormatInt(file.FileSize, 10), file.CreatedAt, file.UpdatedAt, file.FileName})
|
tb.Append([]string{strconv.Itoa(k + 1), file.FileId, converter.ConvertFileSize(file.FileSize, 2), file.ContentHash, strconv.FormatInt(file.FileSize, 10), file.CreatedAt, file.UpdatedAt, file.FileName})
|
||||||
case opSearch:
|
case opSearch:
|
||||||
tb.Append([]string{strconv.Itoa(k), file.FileId, converter.ConvertFileSize(file.FileSize, 2), file.ContentHash, strconv.FormatInt(file.FileSize, 10), file.CreatedAt, file.UpdatedAt, file.Path})
|
tb.Append([]string{strconv.Itoa(k + 1), file.FileId, converter.ConvertFileSize(file.FileSize, 2), file.ContentHash, strconv.FormatInt(file.FileSize, 10), file.CreatedAt, file.UpdatedAt, file.Path})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fN, dN = files.Count()
|
fN, dN = files.Count()
|
||||||
@ -204,15 +204,15 @@ func renderTable(op int, isTotal bool, path string, files aliyunpan.FileList) {
|
|||||||
tb.SetColumnAlignment([]int{tablewriter.ALIGN_DEFAULT, tablewriter.ALIGN_RIGHT, tablewriter.ALIGN_LEFT, tablewriter.ALIGN_LEFT})
|
tb.SetColumnAlignment([]int{tablewriter.ALIGN_DEFAULT, tablewriter.ALIGN_RIGHT, tablewriter.ALIGN_LEFT, tablewriter.ALIGN_LEFT})
|
||||||
for k, file := range files {
|
for k, file := range files {
|
||||||
if file.IsFolder() {
|
if file.IsFolder() {
|
||||||
tb.Append([]string{strconv.Itoa(k), "-", file.UpdatedAt, file.FileName + aliyunpan.PathSeparator})
|
tb.Append([]string{strconv.Itoa(k + 1), "-", file.UpdatedAt, file.FileName + aliyunpan.PathSeparator})
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
switch op {
|
switch op {
|
||||||
case opLs:
|
case opLs:
|
||||||
tb.Append([]string{strconv.Itoa(k), converter.ConvertFileSize(file.FileSize, 2), file.UpdatedAt, file.FileName})
|
tb.Append([]string{strconv.Itoa(k + 1), converter.ConvertFileSize(file.FileSize, 2), file.UpdatedAt, file.FileName})
|
||||||
case opSearch:
|
case opSearch:
|
||||||
tb.Append([]string{strconv.Itoa(k), converter.ConvertFileSize(file.FileSize, 2), file.UpdatedAt, file.Path})
|
tb.Append([]string{strconv.Itoa(k + 1), converter.ConvertFileSize(file.FileSize, 2), file.UpdatedAt, file.Path})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fN, dN = files.Count()
|
fN, dN = files.Count()
|
||||||
|
@ -150,7 +150,7 @@ func RunRecycleList(driveId string) {
|
|||||||
fn = fn + "/"
|
fn = fn + "/"
|
||||||
fs = "-"
|
fs = "-"
|
||||||
}
|
}
|
||||||
tb.Append([]string{strconv.Itoa(k), file.FileId, fn, fs, file.CreatedAt, file.UpdatedAt})
|
tb.Append([]string{strconv.Itoa(k + 1), file.FileId, fn, fs, file.CreatedAt, file.UpdatedAt})
|
||||||
}
|
}
|
||||||
|
|
||||||
tb.Render()
|
tb.Render()
|
||||||
@ -161,7 +161,7 @@ func RunRecycleRestore(driveId string, fidStrList ...string) {
|
|||||||
panClient := GetActivePanClient()
|
panClient := GetActivePanClient()
|
||||||
restoreFileList := []*aliyunpan.FileBatchActionParam{}
|
restoreFileList := []*aliyunpan.FileBatchActionParam{}
|
||||||
|
|
||||||
for _,fid := range fidStrList {
|
for _, fid := range fidStrList {
|
||||||
restoreFileList = append(restoreFileList, &aliyunpan.FileBatchActionParam{
|
restoreFileList = append(restoreFileList, &aliyunpan.FileBatchActionParam{
|
||||||
DriveId: driveId,
|
DriveId: driveId,
|
||||||
FileId: fid,
|
FileId: fid,
|
||||||
@ -190,7 +190,7 @@ func RunRecycleDelete(driveId string, fidStrList ...string) {
|
|||||||
panClient := GetActivePanClient()
|
panClient := GetActivePanClient()
|
||||||
deleteFileList := []*aliyunpan.FileBatchActionParam{}
|
deleteFileList := []*aliyunpan.FileBatchActionParam{}
|
||||||
|
|
||||||
for _,fid := range fidStrList {
|
for _, fid := range fidStrList {
|
||||||
deleteFileList = append(deleteFileList, &aliyunpan.FileBatchActionParam{
|
deleteFileList = append(deleteFileList, &aliyunpan.FileBatchActionParam{
|
||||||
DriveId: driveId,
|
DriveId: driveId,
|
||||||
FileId: fid,
|
FileId: fid,
|
||||||
@ -234,7 +234,7 @@ func RunRecycleClear(driveId string) {
|
|||||||
|
|
||||||
// delete
|
// delete
|
||||||
deleteFileList := []*aliyunpan.FileBatchActionParam{}
|
deleteFileList := []*aliyunpan.FileBatchActionParam{}
|
||||||
for _,f := range fdl {
|
for _, f := range fdl {
|
||||||
deleteFileList = append(deleteFileList, &aliyunpan.FileBatchActionParam{
|
deleteFileList = append(deleteFileList, &aliyunpan.FileBatchActionParam{
|
||||||
DriveId: driveId,
|
DriveId: driveId,
|
||||||
FileId: f.FileId,
|
FileId: f.FileId,
|
||||||
|
@ -87,8 +87,8 @@ func RunRemove(driveId string, paths ...string) {
|
|||||||
}
|
}
|
||||||
fe.Path = absolutePath
|
fe.Path = absolutePath
|
||||||
delFileInfos = append(delFileInfos, &aliyunpan.FileBatchActionParam{
|
delFileInfos = append(delFileInfos, &aliyunpan.FileBatchActionParam{
|
||||||
DriveId:driveId,
|
DriveId: driveId,
|
||||||
FileId:fe.FileId,
|
FileId: fe.FileId,
|
||||||
})
|
})
|
||||||
fileId2FileEntity[fe.FileId] = fe
|
fileId2FileEntity[fe.FileId] = fe
|
||||||
cacheCleanDirs = append(cacheCleanDirs, path.Dir(fe.Path))
|
cacheCleanDirs = append(cacheCleanDirs, path.Dir(fe.Path))
|
||||||
@ -98,7 +98,7 @@ func RunRemove(driveId string, paths ...string) {
|
|||||||
successDelFileEntity := []*aliyunpan.FileEntity{}
|
successDelFileEntity := []*aliyunpan.FileEntity{}
|
||||||
fdr, err := activeUser.PanClient().FileDelete(delFileInfos)
|
fdr, err := activeUser.PanClient().FileDelete(delFileInfos)
|
||||||
if fdr != nil {
|
if fdr != nil {
|
||||||
for _,item := range fdr {
|
for _, item := range fdr {
|
||||||
if !item.Success {
|
if !item.Success {
|
||||||
failedRmPaths = append(failedRmPaths, fileId2FileEntity[item.FileId].Path)
|
failedRmPaths = append(failedRmPaths, fileId2FileEntity[item.FileId].Path)
|
||||||
} else {
|
} else {
|
||||||
@ -111,7 +111,7 @@ func RunRemove(driveId string, paths ...string) {
|
|||||||
tb := cmdtable.NewTable(os.Stdout)
|
tb := cmdtable.NewTable(os.Stdout)
|
||||||
tb.SetHeader([]string{"#", "文件/目录"})
|
tb.SetHeader([]string{"#", "文件/目录"})
|
||||||
for k := range successDelFileEntity {
|
for k := range successDelFileEntity {
|
||||||
tb.Append([]string{strconv.Itoa(k), successDelFileEntity[k].Path})
|
tb.Append([]string{strconv.Itoa(k + 1), successDelFileEntity[k].Path})
|
||||||
}
|
}
|
||||||
tb.Render()
|
tb.Render()
|
||||||
}
|
}
|
||||||
|
@ -306,7 +306,7 @@ func RunShareList() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tb.Append([]string{strconv.Itoa(k), record.ShareId, record.ShareUrl, record.SharePwd,
|
tb.Append([]string{strconv.Itoa(k + 1), record.ShareId, record.ShareUrl, record.SharePwd,
|
||||||
record.ShareName,
|
record.ShareName,
|
||||||
//record.FileIdList[0],
|
//record.FileIdList[0],
|
||||||
et,
|
et,
|
||||||
|
@ -85,8 +85,8 @@ func CmdSu() cli.Command {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if n, err := strconv.Atoi(index); err == nil && n >= 0 && n < numLogins {
|
if n, err1 := strconv.Atoi(index); err1 == nil && (n-1) >= 0 && (n-1) < numLogins {
|
||||||
uid = config.Config.UserList[n].UserId
|
uid = config.Config.UserList[n-1].UserId
|
||||||
} else {
|
} else {
|
||||||
fmt.Printf("切换用户失败, 请检查 # 值是否正确\n")
|
fmt.Printf("切换用户失败, 请检查 # 值是否正确\n")
|
||||||
return nil
|
return nil
|
||||||
|
@ -34,7 +34,7 @@ func (pl *PanUserList) String() string {
|
|||||||
tb.SetHeader([]string{"#", "uid", "用户名", "昵称"})
|
tb.SetHeader([]string{"#", "uid", "用户名", "昵称"})
|
||||||
|
|
||||||
for k, userInfo := range *pl {
|
for k, userInfo := range *pl {
|
||||||
tb.Append([]string{strconv.Itoa(k), userInfo.UserId, userInfo.AccountName, userInfo.Nickname})
|
tb.Append([]string{strconv.Itoa(k + 1), userInfo.UserId, userInfo.AccountName, userInfo.Nickname})
|
||||||
}
|
}
|
||||||
|
|
||||||
tb.Render()
|
tb.Render()
|
||||||
@ -95,7 +95,7 @@ func DecryptString(text string) string {
|
|||||||
if text == "" {
|
if text == "" {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
d, _ := hex.DecodeString(text)
|
d, _ := hex.DecodeString(text)
|
||||||
|
|
||||||
// use the machine unique id as the key
|
// use the machine unique id as the key
|
||||||
// but in some OS, this key will be changed if you reinstall the OS
|
// but in some OS, this key will be changed if you reinstall the OS
|
||||||
@ -120,4 +120,4 @@ func IsFolderExist(pathStr string) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return fi.IsDir()
|
return fi.IsDir()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user