Categorygithub.com/pcj/mobyprogress
modulepackage
0.0.0-20221114203314-669a7801d484
Repository: https://github.com/pcj/mobyprogress.git
Documentation: pkg.go.dev

# README

mobyprogress

ci godoc

The progress bar from the docker/moby project, repackaged as a standalone library.

Have you ever wanted a progress bar for your golang-based CLI tool only to find that the library either does not work on all platforms or does not have multibar support?
Me too! I've always liked the docker cli progress bar so I went ahead and broke it out into it's own library.

Note that since I am not the original author of this code I won't accept new features; this code is considered "complete".

Installation

go get github.com/pcj/mobyprogress@latest

Usage

Create a mobyprogess.Output instance over an io.Writer:

out := mobyprogress.NewOut(os.Stdout)

progress := mobyprogress.NewProgressOutput(out)

Then, send progress updates to the output:

progress.WriteProgress(progress.Progress{
    ID:      "some.tar.gz",
    Action:  "downloading",
    Total:   int64(bytesTotal),
    Current: int64(bytesSent),
    Units:   "bytes",
})

The progress.ID field is used as the key to identify the progress bar to update.

# Functions

ChanOutput returns an Output that writes progress updates to the supplied channel.
DisplayJSONMessagesStream displays a json message stream from `in` to `out`, `isTerminal` describes if `out` is a terminal.
DisplayJSONMessagesToStream prints json messages to the output stream.
FormatError formats the error as a JSON object.
FormatStatus formats the specified objects according to the specified format (and id).
Message is a convenience function to write a progress message to the channel.
Messagef is a convenience function to write a printf-formatted progress message to the channel.
NewJSONProgressOutput returns a progress.Output that formats output using JSON objects.
NewOut returns a new Out object from a Writer.
No description provided by the author
NewProgressReader creates a new ProgressReader.
Update is a convenience function to write a progress update to the channel.
Updatef is a convenience function to write a printf-formatted progress update to the channel.

# Constants

RFC3339NanoFixed is time.RFC3339Nano with nanoseconds padded using zeros to ensure the formatted time isalways the same number of characters.

# Structs

JSONError wraps a concrete Code and Message, `Code` is is an integer error code, `Message` is the error message.
JSONMessage defines a message struct.
JSONProgress describes a Progress.
Out is an output stream used by the DockerCli to write normal program output.
No description provided by the author
Reader is a Reader with progress bar.

# Interfaces

No description provided by the author