command

package
v0.3.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 21, 2024 License: Apache-2.0 Imports: 46 Imported by: 0

Documentation

Overview

Copyright (c) 2020 tickstep.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright (c) 2020 tickstep.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright (c) 2020 tickstep.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright (c) 2020 tickstep.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright (c) 2020 tickstep.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright (c) 2020 tickstep.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright (c) 2020 tickstep.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright (c) 2020 tickstep.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright (c) 2020 tickstep.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright (c) 2020 tickstep.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright (c) 2020 tickstep.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright (c) 2020 tickstep.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright (c) 2020 tickstep.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright (c) 2020 tickstep.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright (c) 2020 tickstep.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright (c) 2020 tickstep.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright (c) 2020 tickstep.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright (c) 2020 tickstep.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright (c) 2020 tickstep.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright (c) 2020 tickstep.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright (c) 2020 tickstep.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

View Source
const (
	// DefaultUploadMaxAllParallel 默认所有文件并发上传数量,即可以同时并发上传多少个文件
	DefaultUploadMaxAllParallel = 1
	// DefaultUploadMaxRetry 默认上传失败最大重试次数
	DefaultUploadMaxRetry = 3
)

Variables

View Source
var (
	// MaxDownloadRangeSize 文件片段最大值
	MaxDownloadRangeSize = 55 * converter.MB

	// DownloadCacheSize 默认每个线程下载缓存大小
	DownloadCacheSize = 64 * converter.KB
)
View Source
var (
	ReloadConfigFunc = func(c *cli.Context) error {
		err := config.Config.Reload()
		if err != nil {
			fmt.Printf("重载配置错误: %s\n", err)
		}
		return nil
	}

	SaveConfigFunc = func(c *cli.Context) error {
		saveConfigMutex.Lock()
		defer saveConfigMutex.Unlock()
		err := config.Config.Save()
		if err != nil {
			fmt.Printf("保存配置错误: %s\n", err)
		}
		return nil
	}
)
View Source
var ErrBadArgs = errors.New("参数错误")
View Source
var ErrNotLogined = errors.New("未登录账号")
View Source
var UploadFlags = []cli.Flag{
	cli.IntFlag{
		Name:  "p",
		Usage: "本次操作文件上传并发数量,即可以同时并发上传多少个文件。0代表跟从配置文件设置(取值范围:1 ~ 20)",
		Value: 0,
	},
	cli.IntFlag{
		Name:  "retry",
		Usage: "上传失败最大重试次数",
		Value: DefaultUploadMaxRetry,
	},
	cli.IntFlag{
		Name:  "timeout",
		Usage: "上传请求超时时间,单位为秒。当遇到网络不好导致上传超时可以尝试调大该值,建议设置30秒以上",
	},
	cli.BoolFlag{
		Name:  "np",
		Usage: "no progress 不展示上传进度条",
	},
	cli.BoolFlag{
		Name:  "ow",
		Usage: "overwrite, 覆盖已存在的同名文件,注意已存在的文件会被移到回收站",
	},
	cli.BoolFlag{
		Name:  "skip",
		Usage: "skip same name, 跳过已存在的同名文件,即使文件内容不一致(不检查SHA1)",
	},
	cli.BoolFlag{
		Name:  "norapid",
		Usage: "不检测秒传。跳过费时的SHA1计算直接上传",
	},
	cli.StringFlag{
		Name:  "driveId",
		Usage: "网盘ID",
		Value: "",
	},
	cli.StringSliceFlag{
		Name:  "exn",
		Usage: "exclude name,指定排除的文件夹或者文件的名称,只支持正则表达式。支持同时排除多个名称,每一个名称就是一个exn参数",
		Value: nil,
	},
	cli.IntFlag{
		Name:  "bs",
		Usage: "block size,上传分片大小,单位KB。推荐值:1024 ~ 10240。当上传极大单文件时候请适当调高该值",
		Value: 10240,
	},
}

Functions

func CmdAlbum added in v0.1.4

func CmdAlbum() cli.Command

func CmdCd

func CmdCd() cli.Command

func CmdConfig

func CmdConfig() cli.Command

func CmdCp added in v0.3.0

func CmdCp() cli.Command

func CmdDownload

func CmdDownload() cli.Command

func CmdDrive

func CmdDrive() cli.Command

func CmdLogin

func CmdLogin() cli.Command

func CmdLoglist

func CmdLoglist() cli.Command

func CmdLogout

func CmdLogout() cli.Command

func CmdLs

func CmdLs() cli.Command

func CmdMkdir

func CmdMkdir() cli.Command

func CmdMv

func CmdMv() cli.Command

func CmdPwd

func CmdPwd() cli.Command

func CmdQuota

func CmdQuota() cli.Command

func CmdRecycle

func CmdRecycle() cli.Command

func CmdRename

func CmdRename() cli.Command

func CmdRm

func CmdRm() cli.Command

func CmdSave added in v0.3.0

func CmdSave() cli.Command

func CmdShare

func CmdShare() cli.Command

func CmdSu

func CmdSu() cli.Command

func CmdSync added in v0.1.6

func CmdSync() cli.Command

func CmdTool

func CmdTool() cli.Command

func CmdTree added in v0.2.0

func CmdTree() cli.Command

func CmdUpload

func CmdUpload() cli.Command

func CmdWho

func CmdWho() cli.Command

func CmdXcp added in v0.2.8

func CmdXcp() cli.Command

func EscapeStr added in v0.0.7

func EscapeStr(s string) string

EscapeStr 转义字符串

func ExportCsv added in v0.1.9

func ExportCsv(savePath string, data [][]string) bool

func GetActivePanClient

func GetActivePanClient() *config.PanClient

func GetActiveUser

func GetActiveUser() *config.PanUser

func GetAllPathFolderByPath added in v0.0.5

func GetAllPathFolderByPath(pathStr string) []string

func NewWebLoginToken added in v0.3.0

func NewWebLoginToken(accessToken string, expired int64) aliyunpan_web.WebLoginToken

func RandomStr

func RandomStr(count int) string

func RefreshOpenTokenInNeed added in v0.3.0

func RefreshOpenTokenInNeed(activeUser *config.PanUser) bool

RefreshOpenTokenInNeed 刷新 openapi access token

func RefreshWebTokenInNeed added in v0.3.0

func RefreshWebTokenInNeed(activeUser *config.PanUser, deviceName string) bool

RefreshWebTokenInNeed 刷新 webapi access token

func RunAlbumAddFile added in v0.1.4

func RunAlbumAddFile(albumName string, filePathList []string, filterOption AlbumFileCategoryOption)

RunAlbumAddFile 增加网盘文件到相簿

func RunAlbumCreate added in v0.1.4

func RunAlbumCreate(name, description string)

func RunAlbumDelete added in v0.1.4

func RunAlbumDelete(nameList []string)

func RunAlbumDownloadFile added in v0.2.8

func RunAlbumDownloadFile(albumNames []string, options *DownloadOptions)

func RunAlbumList added in v0.1.4

func RunAlbumList()

func RunAlbumListFile added in v0.1.4

func RunAlbumListFile(name string)

func RunAlbumRename added in v0.1.4

func RunAlbumRename(name, newName string)

func RunAlbumRmFile added in v0.1.4

func RunAlbumRmFile(name string, nameList []string)

func RunChangeDirectory

func RunChangeDirectory(driveId, targetPath string)

func RunCopy added in v0.3.0

func RunCopy(driveId string, paths ...string)

RunCopy 执行复制文件/目录

func RunDownload

func RunDownload(paths []string, options *DownloadOptions)

RunDownload 执行下载网盘内文件

func RunLogin

func RunLogin() (ticketId string, openapiToken, webapiToken *config.PanClientToken, error error)

func RunLs

func RunLs(driveId, targetPath string, lsOptions *LsOptions,
	orderBy aliyunpan.FileOrderBy, orderDirection aliyunpan.FileOrderDirection)

func RunMkdir

func RunMkdir(driveId, name string)

func RunMove

func RunMove(driveId string, paths ...string)

RunMove 执行移动文件/目录

func RunRecycleClear

func RunRecycleClear(driveId string)

RunRecycleClear 清空回收站

func RunRecycleDelete

func RunRecycleDelete(driveId string, fidStrList ...string)

RunRecycleDelete 执行删除回收站文件或目录

func RunRecycleList

func RunRecycleList(driveId string)

RunRecycleList 执行列出回收站文件列表

func RunRecycleRestore

func RunRecycleRestore(driveId string, fidStrList ...string)

RunRecycleRestore 执行还原回收站文件或目录

func RunRemove

func RunRemove(driveId string, paths ...string)

RunRemove 执行 批量删除文件/目录

func RunRename

func RunRename(driveId string, oldName string, newName string)

func RunRenameBatch added in v0.2.5

func RunRenameBatch(skipConfirm bool, driveId string, expression, replacement, filePattern string)

RunRenameBatch 批量重命名文件

func RunSave added in v0.3.0

func RunSave(driveId string, args ...string)

RunSave 保存分享的文件

func RunShareCancel

func RunShareCancel(shareIdList []string)

RunShareCancel 执行取消分享

func RunShareExport added in v0.1.9

func RunShareExport(option, saveFilePath string)

func RunShareList

func RunShareList()

RunShareList 执行列出分享列表

func RunShareSet

func RunShareSet(modeFlag, driveId string, paths []string, expiredTime string, sharePwd string)

RunShareSet 执行分享

func RunSwitchDriveList

func RunSwitchDriveList(targetDriveId string)

func RunSync added in v0.1.6

func RunSync(defaultTask *syncdrive.SyncTask, cycleMode syncdrive.CycleMode, fileDownloadParallel, fileUploadParallel int, downloadBlockSize, uploadBlockSize int64,
	flag syncdrive.SyncPriorityOption, localDelayTime int, scanTimeInterval int64)

func RunTestShellPattern added in v0.2.4

func RunTestShellPattern(driveId string, pattern string)

RunTestShellPattern 执行测试通配符

func RunTree added in v0.2.0

func RunTree(driveId, pathStr string, showFullPath, showFileSize bool, minSize, maxSize int64)

RunTree 列出树形图

func RunUpload

func RunUpload(localPaths []string, savePath string, opt *UploadOptions)

RunUpload 执行文件上传

func RunXCopy added in v0.2.8

func RunXCopy(srcDriveId, dstDriveId string, paths ...string)

RunXCopy 执行复制文件/目录

func TryLogin added in v0.2.5

func TryLogin() *config.PanUser

TryLogin 尝试登录,基础应用支持的各类登录方式进行尝试成功登录

func UnescapeStr added in v0.0.7

func UnescapeStr(s string) string

UnescapeStr 反转义字符串

Types

type AlbumFileCategoryOption added in v0.1.4

type AlbumFileCategoryOption string
var (
	ImageOnlyOption      AlbumFileCategoryOption = "image"
	VideoOnlyOption      AlbumFileCategoryOption = "video"
	ImageVideoOnlyOption AlbumFileCategoryOption = "image_video"
	AllFileOption        AlbumFileCategoryOption = "none"
)

type DownloadOptions

type DownloadOptions struct {
	IsPrintStatus        bool
	IsExecutedPermission bool
	IsOverwrite          bool
	SaveTo               string
	Parallel             int // 文件下载最大线程数
	SliceParallel        int // 单个文件分片下载最大线程数
	Load                 int
	MaxRetry             int
	NoCheck              bool
	ShowProgress         bool
	DriveId              string
	ExcludeNames         []string // 排除的文件名,包括文件夹和文件。即这些文件/文件夹不进行下载,支持正则表达式
	IsMultiUserDownload  bool     // 是否启用多用户联合下载
}

DownloadOptions 下载可选参数

type LocateDownloadOption

type LocateDownloadOption struct {
	FromPan bool
}

LocateDownloadOption 获取下载链接可选参数

type LsOptions

type LsOptions struct {
	Total bool
}

LsOptions 列目录可选项

type QuotaInfo

type QuotaInfo struct {
	// 已使用个人空间大小
	UsedSize int64
	// 个人空间总大小
	Quota int64
}

func RunGetQuotaInfo

func RunGetQuotaInfo() (quotaInfo *QuotaInfo, error error)

type SearchOptions

type SearchOptions struct {
	Total   bool
	Recurse bool
}

SearchOptions 搜索可选项

type UploadOptions

type UploadOptions struct {
	AllParallel    int // 所有文件并发上传数量,即可以同时并发上传多少个文件
	Parallel       int // 单个文件并发上传数量
	MaxRetry       int
	MaxTimeoutSec  int // http请求超时时间,单位秒
	NoRapidUpload  bool
	ShowProgress   bool
	IsOverwrite    bool // 覆盖已存在的文件,如果同名文件已存在则移到回收站里
	IsSkipSameName bool // 跳过已存在的文件,即使文件内容不一致(不检查SHA1)
	DriveId        string
	ExcludeNames   []string // 排除的文件名,包括文件夹和文件。即这些文件/文件夹不进行上传,支持正则表达式
	BlockSize      int64    // 分片大小
}

UploadOptions 上传可选项

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL