From b5f54a9b23e8d9418700494da9aa78d8db354c43 Mon Sep 17 00:00:00 2001 From: baude Date: Mon, 15 Mar 2021 14:52:43 -0500 Subject: introduce podman machine podman machine allows podman to create, manage, and interact with a vm running some form of linux (default is fcos). podman is then configured to be able to interact with the vm automatically. while this is usable on linux, the real push is to get this working on both current apple architectures in macos. Ashley Cui contributed to this PR and was a great help. [NO TESTS NEEDED] Signed-off-by: baude --- .../vbauerster/mpb/v6/bar_filler_spinner.go | 65 ++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 vendor/github.com/vbauerster/mpb/v6/bar_filler_spinner.go (limited to 'vendor/github.com/vbauerster/mpb/v6/bar_filler_spinner.go') diff --git a/vendor/github.com/vbauerster/mpb/v6/bar_filler_spinner.go b/vendor/github.com/vbauerster/mpb/v6/bar_filler_spinner.go new file mode 100644 index 000000000..0817b19ec --- /dev/null +++ b/vendor/github.com/vbauerster/mpb/v6/bar_filler_spinner.go @@ -0,0 +1,65 @@ +package mpb + +import ( + "io" + "strings" + + "github.com/mattn/go-runewidth" + "github.com/vbauerster/mpb/v6/decor" + "github.com/vbauerster/mpb/v6/internal" +) + +// SpinnerAlignment enum. +type SpinnerAlignment int + +// SpinnerAlignment kinds. +const ( + SpinnerOnLeft SpinnerAlignment = iota + SpinnerOnMiddle + SpinnerOnRight +) + +// SpinnerDefaultStyle is a style for rendering a spinner. +var SpinnerDefaultStyle = []string{"⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"} + +type spinnerFiller struct { + frames []string + count uint + alignment SpinnerAlignment +} + +// NewSpinnerFiller returns a BarFiller implementation which renders +// a spinner. If style is nil or zero length, SpinnerDefaultStyle is +// applied. To be used with `*Progress.Add(...) *Bar` method. +func NewSpinnerFiller(style []string, alignment SpinnerAlignment) BarFiller { + if len(style) == 0 { + style = SpinnerDefaultStyle + } + filler := &spinnerFiller{ + frames: style, + alignment: alignment, + } + return filler +} + +func (s *spinnerFiller) Fill(w io.Writer, reqWidth int, stat decor.Statistics) { + width := internal.CheckRequestedWidth(reqWidth, stat.AvailableWidth) + + frame := s.frames[s.count%uint(len(s.frames))] + frameWidth := runewidth.StringWidth(frame) + + if width < frameWidth { + return + } + + switch rest := width - frameWidth; s.alignment { + case SpinnerOnLeft: + io.WriteString(w, frame+strings.Repeat(" ", rest)) + case SpinnerOnMiddle: + str := strings.Repeat(" ", rest/2) + frame + strings.Repeat(" ", rest/2+rest%2) + io.WriteString(w, str) + case SpinnerOnRight: + io.WriteString(w, strings.Repeat(" ", rest)+frame) + } + s.count++ +} -- cgit v1.2.3-54-g00ecf