mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
pkg/jsonmessage: remove github.com/morikuni/aec dependency
We can probably use [aec.EmptyBuilder] for managing the output, but currently we're doing it all manually, so defining some consts for the basics we use. [aec.EmptyBuilder]: https://pkg.go.dev/github.com/morikuni/aec#EmptyBuilder Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
@@ -9,7 +9,6 @@ import (
|
||||
|
||||
"github.com/docker/go-units"
|
||||
"github.com/moby/term"
|
||||
"github.com/morikuni/aec"
|
||||
)
|
||||
|
||||
// RFC3339NanoFixed is time.RFC3339Nano with nanoseconds padded using zeros to
|
||||
@@ -164,18 +163,27 @@ type JSONMessage struct {
|
||||
Aux *json.RawMessage `json:"aux,omitempty"`
|
||||
}
|
||||
|
||||
// We can probably use [aec.EmptyBuilder] for managing the output, but
|
||||
// currently we're doing it all manually, so defining some consts for
|
||||
// the basics we use.
|
||||
//
|
||||
// [aec.EmptyBuilder]: https://pkg.go.dev/github.com/morikuni/aec#EmptyBuilder
|
||||
const (
|
||||
ansiEraseLine = "\x1b[2K" // Erase entire line
|
||||
ansiCursorUpFmt = "\x1b[%dA" // Move cursor up N lines
|
||||
ansiCursorDownFmt = "\x1b[%dB" // Move cursor down N lines
|
||||
)
|
||||
|
||||
func clearLine(out io.Writer) {
|
||||
eraseMode := aec.EraseModes.All
|
||||
cl := aec.EraseLine(eraseMode)
|
||||
fmt.Fprint(out, cl)
|
||||
_, _ = out.Write([]byte(ansiEraseLine))
|
||||
}
|
||||
|
||||
func cursorUp(out io.Writer, l uint) {
|
||||
fmt.Fprint(out, aec.Up(l))
|
||||
_, _ = fmt.Fprintf(out, ansiCursorUpFmt, l)
|
||||
}
|
||||
|
||||
func cursorDown(out io.Writer, l uint) {
|
||||
fmt.Fprint(out, aec.Down(l))
|
||||
_, _ = fmt.Fprintf(out, ansiCursorDownFmt, l)
|
||||
}
|
||||
|
||||
// Display prints the JSONMessage to out. If isTerminal is true, it erases
|
||||
|
||||
@@ -83,7 +83,6 @@ require (
|
||||
github.com/moby/sys/userns v0.1.0
|
||||
github.com/moby/term v0.5.2
|
||||
github.com/montanaflynn/stats v0.7.1
|
||||
github.com/morikuni/aec v1.0.0
|
||||
github.com/opencontainers/cgroups v0.0.4
|
||||
github.com/opencontainers/go-digest v1.0.0
|
||||
github.com/opencontainers/image-spec v1.1.1
|
||||
@@ -194,6 +193,7 @@ require (
|
||||
github.com/mitchellh/reflectwalk v1.0.2 // indirect
|
||||
github.com/moby/moby/api v0.0.0
|
||||
github.com/moby/moby/client v0.0.0
|
||||
github.com/morikuni/aec v1.0.0 // indirect
|
||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
|
||||
github.com/opencontainers/runtime-tools v0.9.1-0.20221107090550-2e043c6bd626 // indirect
|
||||
github.com/package-url/packageurl-go v0.1.1 // indirect
|
||||
|
||||
Reference in New Issue
Block a user