Documentation ¶
Overview ¶
Package ui contains some simple structs that have nice-looking String() methods for printing console output with unicode characters.
Example ¶
package main import ( "fmt" "github.com/julz/prettyprogress/ui" ) func main() { fmt.Printf("\n%s", ui.Steps{ { Name: "Building..", Bullet: ui.Complete, }, { Name: "Downloading..", Bullet: ui.Downloading, Bar: ui.NewBar(10, 100).String(), }, { Name: "Scanning..", Bullet: ui.Running, Bar: ui.NewBar(20, 100).String(), }, { Name: "Waiting to Start..", Bullet: ui.Future, }, }) }
Output: ✓ Building.. ↡ Downloading.. [██ ] ► Scanning.. [████ ] Waiting to Start..
Index ¶
Examples ¶
Constants ¶
View Source
const DefaultBarEnd = "]"
View Source
const DefaultBarStart = "["
Variables ¶
View Source
var ( RunningState BulletState = "Running" CompleteState BulletState = "Complete" FailedState BulletState = "Failed" Failed Bullet = []string{"✗"} Future Bullet = []string{" "} Running Bullet = []string{"►"} Downloading Bullet = []string{"↡"} Uploading Bullet = []string{"↟"} Complete Bullet = []string{"✓"} AnimatedRunning Bullet = []string{"⠁", "⠂", "⠄", "⡀", "⢀", "⠠", "⠐", "⠈"} AnimatedRunning2 Bullet = []string{"◴", "◷", "◶", "◵"} AnimatedRunning3 Bullet = []string{"◐", "◓", "◑", "◒"} AnimatedRunning4 Bullet = []string{"▉", "▊", "▋", "▌", "▍", "▎", "▏", "▎", "▍", "▌", "▋", "▊", "▉"} AnimatedRunning5 Bullet = []string{"←", "↖", "↑", "↗", "→", "↘", "↓", "↙"} AnimatedRunning6 Bullet = []string{"⣾", "⣽", "⣻", "⢿", "⡿", "⣟", "⣯", "⣷"} )
View Source
var AnimatedBulletSet = BulletSet{ Failed: Failed, Future: Future, Running: AnimatedRunning6, Downloading: Downloading, Uploading: Uploading, Complete: Complete, }
View Source
var ColoredAnimatedBulletSet = BulletSet{ Failed: Failed.WithColor(color.New(color.FgRed)), Future: Future, Running: AnimatedRunning6.WithColor(color.New(color.FgGreen)), Downloading: Downloading, Uploading: Uploading, Complete: Complete, }
View Source
var DefaultBulletSet = BulletSet{ Failed: Failed, Future: Future, Running: Running, Downloading: Downloading, Uploading: Uploading, Complete: Complete, }
Functions ¶
func PercentageLabel ¶
Types ¶
type Bar ¶
type Bar struct { Progress int Total int Width int StartChar string EndChar string LabelFunc LabelFunc }
Bar is a simple progress bar struct that knows how to String() itself in a pretty way
Example ¶
package main import ( "fmt" "github.com/julz/prettyprogress/ui" ) func main() { fmt.Printf("%s", ui.Bar{ Width: 5, Total: 100, Progress: 40, }) }
Output: [██ ]
func NewBarWithWidth ¶
NewBarWithWidth creates a new Bar with the given progress, total and width
type BulletState ¶
type BulletState string
type Step ¶
Step represents a single step It is formatted as `$Bullet $Name $Bar` with appropriate spacing
Example ¶
package main import ( "fmt" "github.com/julz/prettyprogress/ui" ) func main() { fmt.Printf("%s", ui.Step{ Bullet: ui.Downloading, Name: "Downloading..", Bar: "[██ ]", }) }
Output: ↡ Downloading.. [██ ]
func (Step) AnimatedString ¶
AnimatedString returns the Step's string output for a given frame
type Steps ¶
type Steps []Step
Steps is a series of steps neccesary to complete the task
func (Steps) AnimatedString ¶
AnimatedString outputs the steps as a nicely formatted string with the given frame of any bullets shown
Click to show internal directories.
Click to hide internal directories.