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.
Index ¶
- func IsTerminal(file *os.File) bool
- type DownloadDashboard
- func (db *DownloadDashboard) Close()
- func (db *DownloadDashboard) Logf(format string, a ...interface{})
- func (db *DownloadDashboard) MarkTaskState(id string, state TaskState, message string)
- func (db *DownloadDashboard) RegisterTask(id, path string, total int64, isFile bool)
- func (db *DownloadDashboard) Start()
- func (db *DownloadDashboard) UpdateTaskInfo(id, name string, total int64, isFile bool)
- func (db *DownloadDashboard) UpdateTaskProgress(id string, downloaded, total, speed int64, eta time.Duration)
- type DownloadDashboardOptions
- type TaskState
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsTerminal ¶
IsTerminal 判断输出环境,是否是输出到终端界面,如果重定向到文件则不用进行下载统计打印输出了
Types ¶
type DownloadDashboard ¶
type DownloadDashboard struct {
// contains filtered or unexported fields
}
DownloadDashboard 下载任务统计面板使用了很多ANSI转义序列。并不是所有的终端都支持ANSI转义序列,所以需要做兼容性处理。
func NewDownloadDashboard ¶
func NewDownloadDashboard(parallel int, globalSpeeds *speeds.Speeds, opts *DownloadDashboardOptions) *DownloadDashboard
NewDownloadDashboard 创建下载任务统计面板
func (*DownloadDashboard) Logf ¶
func (db *DownloadDashboard) Logf(format string, a ...interface{})
Logf 增加日志
func (*DownloadDashboard) MarkTaskState ¶
func (db *DownloadDashboard) MarkTaskState(id string, state TaskState, message string)
MarkTaskState 标记任务状态
func (*DownloadDashboard) RegisterTask ¶
func (db *DownloadDashboard) RegisterTask(id, path string, total int64, isFile bool)
RegisterTask 注册任务信息
func (*DownloadDashboard) UpdateTaskInfo ¶
func (db *DownloadDashboard) UpdateTaskInfo(id, name string, total int64, isFile bool)
UpdateTaskInfo 更新任务信息
func (*DownloadDashboard) UpdateTaskProgress ¶
func (db *DownloadDashboard) UpdateTaskProgress(id string, downloaded, total, speed int64, eta time.Duration)
UpdateTaskProgress 更新任务进度