1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

vet: hide skipped file messages behind verbose flag (#9823)

This commit is contained in:
Lukas Neubert 2021-04-20 16:20:50 +02:00 committed by GitHub
parent 16e79bc3ca
commit 0b0a5de9e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 19 deletions

View File

@ -27,16 +27,17 @@ struct Options {
use_color bool use_color bool
} }
const vet_options = cmdline.options_after(os.args, ['vet']) const term_colors = term.can_show_color_on_stderr()
fn main() { fn main() {
vet_options := cmdline.options_after(os.args, ['vet'])
mut vt := Vet{ mut vt := Vet{
opt: Options{ opt: Options{
is_force: '-force' in vet_options is_force: '-force' in vet_options
is_werror: '-W' in vet_options is_werror: '-W' in vet_options
is_verbose: '-verbose' in vet_options || '-v' in vet_options is_verbose: '-verbose' in vet_options || '-v' in vet_options
show_warnings: '-hide-warnings' !in vet_options show_warnings: '-hide-warnings' !in vet_options && '-w' !in vet_options
use_color: should_use_color() use_color: '-color' in vet_options || (term_colors && '-nocolor' !in vet_options)
} }
} }
mut paths := cmdline.only_non_options(vet_options) mut paths := cmdline.only_non_options(vet_options)
@ -88,7 +89,7 @@ fn (mut vt Vet) vet_file(path string) {
// skip all /tests/ files, since usually their content is not // skip all /tests/ files, since usually their content is not
// important enough to be documented/vetted, and they may even // important enough to be documented/vetted, and they may even
// contain intentionally invalid code. // contain intentionally invalid code.
eprintln("skipping test file: '$path' ...") vt.vprintln("skipping test file: '$path' ...")
return return
} }
vt.file = path vt.file = path
@ -252,14 +253,3 @@ fn (mut vt Vet) warn(msg string, line int, fix vet.FixKind) {
vt.warns << w vt.warns << w
} }
} }
fn should_use_color() bool {
mut color := term.can_show_color_on_stderr()
if '-nocolor' in vet_options {
color = false
}
if '-color' in vet_options {
color = true
}
return color
}

View File

@ -5,7 +5,14 @@ Usage:
Reports suspicious code constructs. Reports suspicious code constructs.
Options: Options:
-W Exit with code 1, even if vet only reported warnings. Useful for checks in CI. -W
-hide-warnings Do not print warnings to stderr. Exit with code 1, even if vet only reported warnings. Useful for checks in CI.
-v, -verbose Enable verbose logging.
-force (NB: vet development only!) Do not skip the vet regression tests. -w, -hide-warnings
Do not print warnings to stderr.
-v, -verbose
Enable verbose logging.
-force
(NB: vet development only!) Do not skip the vet regression tests.