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.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 {
|
||||
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()})
|
||||
}
|
||||
tb.Render()
|
||||
|
@ -71,8 +71,8 @@ func RunSwitchDriveList(targetDriveId string) {
|
||||
return
|
||||
}
|
||||
|
||||
if n, err := strconv.Atoi(index); err == nil && n >= 0 && n < len(driveList) {
|
||||
activeDriveInfo = driveList[n]
|
||||
if n, err1 := strconv.Atoi(index); err1 == nil && (n-1) >= 0 && (n-1) < len(driveList) {
|
||||
activeDriveInfo = driveList[n-1]
|
||||
} else {
|
||||
fmt.Printf("切换网盘失败, 请检查 # 值是否正确\n")
|
||||
return
|
||||
@ -121,7 +121,7 @@ func getDriveOptionList() (config.DriveInfoList, string) {
|
||||
tb.SetHeader([]string{"#", "drive_id", "网盘名称"})
|
||||
|
||||
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()
|
||||
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})
|
||||
for k, file := range files {
|
||||
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
|
||||
}
|
||||
|
||||
switch op {
|
||||
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:
|
||||
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()
|
||||
@ -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})
|
||||
for k, file := range files {
|
||||
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
|
||||
}
|
||||
|
||||
switch op {
|
||||
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:
|
||||
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()
|
||||
|
@ -150,7 +150,7 @@ func RunRecycleList(driveId string) {
|
||||
fn = fn + "/"
|
||||
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()
|
||||
|
@ -111,7 +111,7 @@ func RunRemove(driveId string, paths ...string) {
|
||||
tb := cmdtable.NewTable(os.Stdout)
|
||||
tb.SetHeader([]string{"#", "文件/目录"})
|
||||
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()
|
||||
}
|
||||
|
@ -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.FileIdList[0],
|
||||
et,
|
||||
|
@ -85,8 +85,8 @@ func CmdSu() cli.Command {
|
||||
return nil
|
||||
}
|
||||
|
||||
if n, err := strconv.Atoi(index); err == nil && n >= 0 && n < numLogins {
|
||||
uid = config.Config.UserList[n].UserId
|
||||
if n, err1 := strconv.Atoi(index); err1 == nil && (n-1) >= 0 && (n-1) < numLogins {
|
||||
uid = config.Config.UserList[n-1].UserId
|
||||
} else {
|
||||
fmt.Printf("切换用户失败, 请检查 # 值是否正确\n")
|
||||
return nil
|
||||
|
@ -34,7 +34,7 @@ func (pl *PanUserList) String() string {
|
||||
tb.SetHeader([]string{"#", "uid", "用户名", "昵称"})
|
||||
|
||||
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()
|
||||
|
Loading…
Reference in New Issue
Block a user