Skip to content

Commit 37cb109

Browse files
committed
feat: add --plain-progress
Signed-off-by: Joseph Kato <joseph@jdkato.io>
1 parent 12fbbd7 commit 37cb109

4 files changed

Lines changed: 34 additions & 28 deletions

File tree

‎cmd/vale/command.go‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,10 +165,13 @@ func sync(_ []string, flags *core.CLIFlags) error {
165165

166166
// A progress bar is for someone watching it. Redirected into a CI log it
167167
// leaves a trail of redrawn frames and, at the end, no record of what was
168-
// actually installed -- so where nobody is watching, each package reports
169-
// itself on its own line instead. See #1138.
168+
// actually installed -- so `--plain-progress` swaps it for a line per
169+
// package. See #1138.
170+
//
171+
// Asked for rather than inferred: a run that has been piped somewhere for
172+
// years should keep printing what it always printed.
170173
var bar *pterm.ProgressbarPrinter
171-
if isTTY(os.Stdout) {
174+
if !flags.PlainProgress {
172175
bar, err = pterm.DefaultProgressbar.WithTotal(len(pkgs)).Start()
173176
if err != nil {
174177
return err

‎cmd/vale/flag.go‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ func init() {
3030
`The minimum level to display (--minAlertLevel=error).`)
3131

3232
pflag.BoolVar(&Flags.NoColor, "no-color", false, "Don't colorize CLI output.")
33+
pflag.BoolVar(&Flags.PlainProgress, "plain-progress", false,
34+
"Log each step instead of drawing a progress bar.")
3335
pflag.BoolVar(&Flags.Wrap, "no-wrap", false, "Don't wrap CLI output.")
3436
pflag.BoolVar(&Flags.NoExit, "no-exit", false, "Don't return a nonzero exit code on errors.")
3537
pflag.BoolVar(&Flags.Simple, "ignore-syntax", false, "Lint all files line-by-line.")

‎internal/core/config.go‎

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -164,27 +164,28 @@ func DefaultStylesPath() (string, error) {
164164
//
165165
// For example, `vale --minAlertLevel=error`.
166166
type CLIFlags struct {
167-
AlertLevel string
168-
Built string
169-
Glob string
170-
InExt string
171-
InPath string
172-
Output string
173-
Path string
174-
Sources string
175-
Filter string
176-
Local bool
177-
NoExit bool
178-
NoColor bool
179-
Normalize bool
180-
Relative bool
181-
Remote bool
182-
Simple bool
183-
Sorted bool
184-
Wrap bool
185-
Version bool
186-
Help bool
187-
IgnoreGlobal bool
167+
AlertLevel string
168+
Built string
169+
Glob string
170+
InExt string
171+
InPath string
172+
Output string
173+
Path string
174+
Sources string
175+
Filter string
176+
Local bool
177+
NoExit bool
178+
NoColor bool
179+
PlainProgress bool
180+
Normalize bool
181+
Relative bool
182+
Remote bool
183+
Simple bool
184+
Sorted bool
185+
Wrap bool
186+
Version bool
187+
Help bool
188+
IgnoreGlobal bool
188189
}
189190

190191
// Config holds the configuration values from both the CLI and `.vale.ini`.

‎testdata/e2e/pkg.yaml‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ dir: fixtures/pkg
44

55
cases:
66
- name: plain-progress
7-
about: "a progress bar redraws itself into a CI log and leaves no record of
8-
what was installed; where stdout is not a terminal, each package reports
9-
itself on its own line instead. See #1138."
7+
about: "a progress bar redraws itself into a CI log and leaves no record
8+
of what was installed; `--plain-progress` swaps it for a line per package.
9+
See #1138."
1010
dir: style
11-
args: sync
11+
args: sync --plain-progress
1212
exit: 0
1313
contains: |
1414
Synced write-good

0 commit comments

Comments
 (0)