progress

package module
v0.0.0-...-f948426 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2022 License: MIT Imports: 6 Imported by: 7

README

💯 progress-go

Build Status Go Report Card codecov license

logo

Go simple progress bar writing to output

📖 ABOUT

Contributors:

Want to contribute ? Feel free to send pull requests!

Have problems, bugs, feature ideas? We are using the github issue tracker to manage them.

📚 Documentation

For examples visit godoc#pkg-examples

For GoDoc reference, visit pkg.go.dev

🚏 HOW TO USE

Progress Bar CLI

🏫 Basic example

package main

import (
	"log"

	"github.com/vardius/progress-go"
)

func main() {
	bar := progress.New(0, 10)

	_, _ = bar.Start()
	defer func() {
		if _, err := bar.Stop(); err != nil {
			log.Printf("failed to finish progress: %v", err)
		}
	}()

	for i := 0; i < 10; i++ {
		_, _ = bar.Advance(1)
	}
}

📜 License

This package is released under the MIT license. See the complete license in the package.

Documentation

Overview

Package progress provides simple progress bar writing to output

Example
package main

import (
	"bytes"
	"fmt"
	"io"
	"log"

	"github.com/vardius/progress-go"
)

func main() {
	const totalIterations = 10

	var b bytes.Buffer
	bar := progress.New(0, totalIterations, progress.Options{
		// Verbose: true,
		Output: io.Writer(&b),
		Graph:  "#",
	})

	_, _ = bar.Start()

	for i := 0; i < totalIterations; i++ {
		_, _ = bar.Advance(1)
	}

	if _, err := bar.Stop(); err != nil {
		log.Printf("failed to finish progress: %v", err)
	}

	fmt.Println(b.String())
	//      10/10 [##################################################] 100%
}

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bar

type Bar struct {
	// contains filtered or unexported fields
}

func New

func New(start, max int64, opts ...Options) *Bar

func (*Bar) Advance

func (bar *Bar) Advance(inc int64) (n int, err error)

func (*Bar) Start

func (bar *Bar) Start() (n int, err error)

func (*Bar) Stop

func (bar *Bar) Stop() (n int, err error)

type Options

type Options struct {
	Output  io.Writer
	Graph   string
	Verbose bool
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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