tools: implement progres bar for `v check-md .`
parent
79284f0458
commit
19e4f5ec73
|
@ -14,6 +14,7 @@ const (
|
|||
too_long_line_length = 100
|
||||
term_colors = term.can_show_color_on_stderr()
|
||||
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..])
|
||||
)
|
||||
|
||||
|
@ -41,6 +42,10 @@ fn main() {
|
|||
println('´-all´ flag is deprecated. Please use ´v check-md .´ instead.')
|
||||
exit(1)
|
||||
}
|
||||
if show_progress {
|
||||
// this is intended to be replaced by the progress lines
|
||||
println('')
|
||||
}
|
||||
mut files_paths := non_option_args.clone()
|
||||
mut res := CheckResult{}
|
||||
if term_colors {
|
||||
|
@ -64,6 +69,9 @@ fn main() {
|
|||
}
|
||||
res += mdfile.check()
|
||||
}
|
||||
if res.errors == 0 && show_progress {
|
||||
term.clear_previous_line()
|
||||
}
|
||||
if res.warnings > 0 || res.errors > 0 || res.oks > 0 {
|
||||
println('\nWarnings: $res.warnings | Errors: $res.errors | OKs: $res.oks')
|
||||
}
|
||||
|
@ -145,9 +153,17 @@ mut:
|
|||
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 {
|
||||
mut res := CheckResult{}
|
||||
for j, line in f.lines {
|
||||
// f.progress('line: $j')
|
||||
if line.len > too_long_line_length {
|
||||
if f.state == .vexample {
|
||||
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(' ')
|
||||
nofmt := 'nofmt' 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) }
|
||||
match command {
|
||||
'compile' {
|
||||
|
|
|
@ -7,6 +7,7 @@ Usage:
|
|||
Note: You can also combine files and directories.
|
||||
|
||||
Flags:
|
||||
-silent Do not show a progress bar.
|
||||
-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.
|
||||
|
|
Loading…
Reference in New Issue