Documentation ¶
Index ¶
- Constants
- Variables
- func AddDecorator(name string, decorator Decorator)
- func RemoveDecorator(name string)
- type Decorator
- type FrameContext
- type Pool
- func (p *Pool) AddBar(bar *Progress) int
- func (p *Pool) FinishAll()
- func (p *Pool) IsFinished() bool
- func (p *Pool) NewBar(max int) *Progress
- func (p *Pool) NewBar64(max int64) *Progress
- func (p *Pool) NewBarDef() *Progress
- func (p *Pool) RemoveBar(bar *Progress) int
- func (p *Pool) Start() *Pool
- func (p *Pool) Update()
- func (p *Pool) Wait()
- type Progress
- func (p *Progress) Add(incSize int) *Progress
- func (p *Progress) Add64(incSize int64) *Progress
- func (p *Progress) Finish()
- func (p *Progress) FinishPrint(str string)
- func (p *Progress) GetCurrent() int64
- func (p *Progress) GetMax() int64
- func (p *Progress) GetWidth() int
- func (p *Progress) Inc() *Progress
- func (p *Progress) IsFinished() bool
- func (pb *Progress) NewProxyReader(r io.Reader) *Reader
- func (pb *Progress) NewProxyWriter(r io.Writer) *Writer
- func (p *Progress) Prefix(prefix string) *Progress
- func (p *Progress) Reset(max int) *Progress
- func (p *Progress) Reset64(max int64) *Progress
- func (pb *Progress) ResetTemplate() error
- func (p *Progress) Set(newValue int) *Progress
- func (p *Progress) Set64(newValue int64) *Progress
- func (p *Progress) SetMax(max int) *Progress
- func (p *Progress) SetMax64(max int64) *Progress
- func (p *Progress) SetMaxWidth(maxWidth int) *Progress
- func (pb *Progress) SetTemplate(template string) error
- func (p *Progress) SetWidth(width int) *Progress
- func (p *Progress) Start() *Progress
- func (p *Progress) String() string
- func (p *Progress) Update()
- type Reader
- type TemplateParser
- type Writer
Constants ¶
View Source
const DefaultTemplate = `{{prefix . 2}} {{bar . 5}} {{percent . 1}} {{counter . 1}} {{speed . 1}} {{timeSpent . 1}} {{timeLeft . 1}}`
Variables ¶
View Source
var Colors = template.FuncMap{ "black": color.New(color.FgBlack).SprintFunc(), "red": color.New(color.FgRed).SprintFunc(), "green": color.New(color.FgGreen).SprintFunc(), "yellow": color.New(color.FgYellow).SprintFunc(), "blue": color.New(color.FgBlue).SprintFunc(), "magenta": color.New(color.FgMagenta).SprintFunc(), "cyan": color.New(color.FgCyan).SprintFunc(), "white": color.New(color.FgWhite).SprintFunc(), "resetcolor": color.New(color.Reset).SprintFunc(), "rndcolor": rndcolor, }
View Source
var Decorators = template.FuncMap{
"bar": adaptativeDecorator(bar),
"prefix": wrapDecorator(prefix),
"counter": wrapDecorator(counter),
"timeSpent": wrapDecorator(timeSpent),
"speed": wrapDecorator(speed),
"percent": wrapDecorator(percent),
"timeLeft": wrapDecorator(timeLeft),
"spin": wrapDecorator(spin),
"frameNo": wrapDecorator(frameNo),
}
Functions ¶
func AddDecorator ¶
func RemoveDecorator ¶
func RemoveDecorator(name string)
Types ¶
type Decorator ¶
type Decorator func(frame *FrameContext, cols int) string
type FrameContext ¶
type FrameContext struct { Current int64 Max int64 Width int MessagePrefix string IsFinish bool // contains filtered or unexported fields }
func NewFrame ¶
func NewFrame(bar *Progress, current, max int64, width int, frameNo int64) *FrameContext
func (*FrameContext) Copy ¶
func (f *FrameContext) Copy() *FrameContext
func (*FrameContext) Format ¶
func (f *FrameContext) Format() *format.ProgressFormat
func (*FrameContext) FrameNo ¶
func (f *FrameContext) FrameNo() int64
type Pool ¶
func (*Pool) IsFinished ¶
type Progress ¶
type Progress struct { ID int Previous int64 RefreshRate time.Duration UnitsWidth int Output io.Writer Width int ForceWidth bool Format format.ProgressFormat Units format.Units // contains filtered or unexported fields }
func (*Progress) FinishPrint ¶
func (*Progress) GetCurrent ¶
func (*Progress) IsFinished ¶
func (*Progress) ResetTemplate ¶ added in v1.0.0
func (*Progress) SetMaxWidth ¶
func (*Progress) SetTemplate ¶ added in v1.0.0
type TemplateParser ¶
type TemplateParser struct {
// contains filtered or unexported fields
}
+-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----+ | C1 | C2 | C3 | C4 | C5 | C6 | C7 | C8 | C9 | C10 | C11 | C12 | +-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----+ Like bootstrap grid system
func NewTemplateParser ¶
func NewTemplateParser(templateString string) (*TemplateParser, error)
func NewTemplateParserEmpty ¶
func NewTemplateParserEmpty() *TemplateParser
func (*TemplateParser) Last ¶
func (tp *TemplateParser) Last() string
func (*TemplateParser) UpdateFrame ¶
func (tp *TemplateParser) UpdateFrame(frame *FrameContext)
func (*TemplateParser) UpdateTemplate ¶
func (tp *TemplateParser) UpdateTemplate(templateString string) error
Source Files ¶
Click to show internal directories.
Click to hide internal directories.