本文整理匯總了Golang中github.com/cheggaaa/pb.ProgressBar.Set64方法的典型用法代碼示例。如果您正苦於以下問題:Golang ProgressBar.Set64方法的具體用法?Golang ProgressBar.Set64怎麽用?Golang ProgressBar.Set64使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/cheggaaa/pb.ProgressBar
的用法示例。
在下文中一共展示了ProgressBar.Set64方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: updateProgress
func (ld *loader) updateProgress(bar *pb.ProgressBar) {
bar.Set64(ld.r.BytesRead())
}
示例2: install
func install(l, version string) error {
var currentStep lang.Step
var bar *pb.ProgressBar
var process *Process
fmt.Printf("Installing %[email protected]%s\n", l, version)
err := service.Install(l, version, binaryFlag, func(step lang.Step, progress, total int64) {
if currentStep != step {
if bar != nil {
bar.NotPrint = true
bar.Finish()
fmt.Printf(ascii2.EraseLine)
bar = nil
}
if process != nil {
process.Done("")
process = nil
}
if total > 0 {
bar = pb.New64(total).Prefix(" " + stepToMsg(step) + "\t\t")
bar.SetWidth(40)
bar.ShowCounters = false
//fmt.Printf("%s\n", step)
//bar.NotPrint = true
bar.Start()
currentStep = step
} else {
process := &Process{Msg: stepToMsg(step) + "\t\t"}
process.Start()
}
}
if bar != nil {
bar.Set64(progress)
}
})
if bar != nil {
bar.NotPrint = true
bar.Finish()
fmt.Printf(ascii2.EraseLines(2) + ascii2.EraseLine + fmt.Sprintf(" %s installed", l))
}
if process != nil {
process.Done("\n")
}
//fmt.Printf(ascii2.EraseLine + ascii2.CursorUp(1) + ascii2.EraseLine)
if err != nil {
fmt.Printf("Could not install %[email protected]%s: \n %s\n", l, version, err.Error())
} else {
fmt.Printf(" %[email protected]%s installed!\n\n", l, version)
}
return err
}
示例3: init
Short: "A brief description of your command",
Long: `A longer description that spans multiple lines and likely contains examples
and usage of using your command. For example:
Cobra is a CLI library for Go that empowers applications.
This application is a tool to generate the needed files
to quickly create a Cobra application.`,
Run: func(cmd *cobra.Command, args []string) {
// TODO: Work your own magic here
var bar *pb.ProgressBar
err := service.Update(func(step lang.Step, p, t int64) {
if bar == nil {
bar = createBar("Updating manifests", t)
}
bar.Set64(p)
})
if bar != nil {
bar.Finish()
}
if err != nil {
printError(err)
}
},
}
func init() {
RootCmd.AddCommand(updateCmd)
示例4: updateProgress
func (d *dumper) updateProgress(bar *pb.ProgressBar) {
bar.Set64(d.f.Stats().BytesRead)
}
示例5: updateProgress
func (d *deleter) updateProgress(bar *pb.ProgressBar) {
bar.Set64(d.del.Completed())
}
示例6:
bar.SetWidth(40)
bar.ShowCounters = false
//fmt.Printf("%s\n", step)
//bar.NotPrint = true
bar.Start()
currentStep = step
} else {
process := &Process{Msg: " " + stepToMsg(step) + "\t\t"}
process.Start()
}
}
if bar != nil {
bar.Set64(progress)
}
})
if bar != nil {
bar.NotPrint = true
bar.Finish()
fmt.Printf(ascii2.EraseLines(2) + ascii2.EraseLine + "\r installed")
}
/*if bar != nil {
bar.NotPrint = true
bar.FinishPrint(ascii2.EraseLine + ascii2.CursorUp(1) + ascii2.EraseLine + " " + stepToMsg(currentStep) + "\t\tDone")
}
if process != nil {
示例7: finishProgressBar
func finishProgressBar(pb *pb.ProgressBar) {
pb.Set64(pb.Total)
pb.Finish()
}