Skip to content

Commit 6828f8b

Browse files
committed
Add noopPending to not render pending updates in no TTY-like environments
Pending defaulted to PendingSimple when we detected that we are in a non-TTY environment but the output is quite noisy and is more suited for verbose output. We add `noopPending` which is used when: - not in a TTY environment - not in verbose mode While testing, I noticed that the `-v` flag does not activate verbose mode, which is something that we should fix when this command is migrated to urfave/cli
1 parent 47598b0 commit 6828f8b

3 files changed

Lines changed: 23 additions & 2 deletions

File tree

cmd/src/doc.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ Examples:
4242
return err
4343
}
4444

45+
// TODO(burmudar): verbose flag doesn't work here. When this command is migrated we need to wire it up properly
4546
out := output.NewOutput(flagSet.Output(), output.OutputOpts{Verbose: *verbose})
4647
if *outputFlag == "" {
4748
out.WriteLine(output.Line(output.EmojiFailure, output.StyleWarning, "output directory must be set via -o"))

lib/output/pending.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,12 @@ type Pending interface {
1818
}
1919

2020
func newPending(message FancyLine, o *Output) Pending {
21-
if !o.caps.Isatty {
21+
if o.caps.Isatty {
22+
return newPendingTTY(message, o)
23+
}
24+
if o.verbose {
2225
return newPendingSimple(message, o)
2326
}
2427

25-
return newPendingTTY(message, o)
28+
return &noopPending{}
2629
}

lib/output/pending_noop.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package output
2+
3+
type noopPending struct{}
4+
5+
var _ Pending = &noopPending{}
6+
7+
func (n *noopPending) Close() {}
8+
func (n *noopPending) Complete(message FancyLine) {}
9+
func (n *noopPending) Destroy() {}
10+
func (n *noopPending) Update(s string) {}
11+
func (n *noopPending) Updatef(format string, args ...any) {}
12+
func (n *noopPending) Verbose(s string) {}
13+
func (n *noopPending) VerboseLine(line FancyLine) {}
14+
func (n *noopPending) Verbosef(format string, args ...any) {}
15+
func (n *noopPending) Write(s string) {}
16+
func (n *noopPending) WriteLine(line FancyLine) {}
17+
func (n *noopPending) Writef(format string, args ...any) {}

0 commit comments

Comments
 (0)