tools: implement progres bar for `v check-md .`
parent
79284f0458
commit
19e4f5ec73
|
@ -14,6 +14,7 @@ const (
|
||||||
too_long_line_length = 100
|
too_long_line_length = 100
|
||||||
term_colors = term.can_show_color_on_stderr()
|
term_colors = term.can_show_color_on_stderr()
|
||||||
hide_warnings = '-hide-warnings' in os.args || '-w' in os.args
|
hide_warnings = '-hide-warnings' in os.args || '-w' in os.args
|
||||||
|
show_progress = os.getenv('GITHUB_JOB') == '' && '-silent' !in os.args
|
||||||
non_option_args = cmdline.only_non_options(os.args[2..])
|
non_option_args = cmdline.only_non_options(os.args[2..])
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -41,6 +42,10 @@ fn main() {
|
||||||
println('´-all´ flag is deprecated. Please use ´v check-md .´ instead.')
|
println('´-all´ flag is deprecated. Please use ´v check-md .´ instead.')
|
||||||
exit(1)
|
exit(1)
|
||||||
}
|
}
|
||||||
|
if show_progress {
|
||||||
|
// this is intended to be replaced by the progress lines
|
||||||
|
println('')
|
||||||
|
}
|
||||||
mut files_paths := non_option_args.clone()
|
mut files_paths := non_option_args.clone()
|
||||||
mut res := CheckResult{}
|
mut res := CheckResult{}
|
||||||
if term_colors {
|
if term_colors {
|
||||||
|
@ -64,6 +69,9 @@ fn main() {
|
||||||
}
|
}
|
||||||
res += mdfile.check()
|
res += mdfile.check()
|
||||||
}
|
}
|
||||||
|
if res.errors == 0 && show_progress {
|
||||||
|
term.clear_previous_line()
|
||||||
|
}
|
||||||
if res.warnings > 0 || res.errors > 0 || res.oks > 0 {
|
if res.warnings > 0 || res.errors > 0 || res.oks > 0 {
|
||||||
println('\nWarnings: $res.warnings | Errors: $res.errors | OKs: $res.oks')
|
println('\nWarnings: $res.warnings | Errors: $res.errors | OKs: $res.oks')
|
||||||
}
|
}
|
||||||
|
@ -145,9 +153,17 @@ mut:
|
||||||
state MDFileParserState = .markdown
|
state MDFileParserState = .markdown
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn (mut f MDFile) progress(message string) {
|
||||||
|
if show_progress {
|
||||||
|
term.clear_previous_line()
|
||||||
|
println('File: ${f.path:-30s}, Lines: ${f.lines.len:5}, $message')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn (mut f MDFile) check() CheckResult {
|
fn (mut f MDFile) check() CheckResult {
|
||||||
mut res := CheckResult{}
|
mut res := CheckResult{}
|
||||||
for j, line in f.lines {
|
for j, line in f.lines {
|
||||||
|
// f.progress('line: $j')
|
||||||
if line.len > too_long_line_length {
|
if line.len > too_long_line_length {
|
||||||
if f.state == .vexample {
|
if f.state == .vexample {
|
||||||
wprintln(wline(f.path, j, line.len, 'long V example line'))
|
wprintln(wline(f.path, j, line.len, 'long V example line'))
|
||||||
|
@ -265,6 +281,7 @@ fn (mut f MDFile) check_examples() CheckResult {
|
||||||
mut acommands := e.command.split(' ')
|
mut acommands := e.command.split(' ')
|
||||||
nofmt := 'nofmt' in acommands
|
nofmt := 'nofmt' in acommands
|
||||||
for command in acommands {
|
for command in acommands {
|
||||||
|
f.progress('example from $e.sline to $e.eline, command: $command')
|
||||||
fmt_res := if nofmt { 0 } else { get_fmt_exit_code(vfile, vexe) }
|
fmt_res := if nofmt { 0 } else { get_fmt_exit_code(vfile, vexe) }
|
||||||
match command {
|
match command {
|
||||||
'compile' {
|
'compile' {
|
||||||
|
|
|
@ -7,6 +7,7 @@ Usage:
|
||||||
Note: You can also combine files and directories.
|
Note: You can also combine files and directories.
|
||||||
|
|
||||||
Flags:
|
Flags:
|
||||||
|
-silent Do not show a progress bar.
|
||||||
-w, -hide-warnings Do not print warnings, only errors.
|
-w, -hide-warnings Do not print warnings, only errors.
|
||||||
|
|
||||||
NB: There are several special keywords, which you can put after the code fences for v.
|
NB: There are several special keywords, which you can put after the code fences for v.
|
||||||
|
|
Loading…
Reference in New Issue