From 39a9beb9e0a6f46da22d51957e07fd9d37f91f68 Mon Sep 17 00:00:00 2001 From: Lukas Neubert Date: Tue, 16 Mar 2021 18:49:06 +0100 Subject: [PATCH] vet: add -W flag and detailed help (#9331) --- cmd/tools/vvet/vvet.v | 4 +++- cmd/v/help/default.txt | 2 +- cmd/v/help/vet.txt | 11 +++++++++++ 3 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 cmd/v/help/vet.txt diff --git a/cmd/tools/vvet/vvet.v b/cmd/tools/vvet/vvet.v index f617c00d67..303c62ca0c 100644 --- a/cmd/tools/vvet/vvet.v +++ b/cmd/tools/vvet/vvet.v @@ -32,6 +32,8 @@ const vet_options = cmdline.options_after(os.args, ['vet']) const is_force = '-force' in vet_options +const is_werror = '-W' in vet_options + const is_verbose = '-verbose' in vet_options || '-v' in vet_options const show_warnings = '-hide-warnings' !in vet_options @@ -104,7 +106,7 @@ fn main() { if errors_vfmt.len > 0 { eprintln('NB: You can run `v fmt -w file.v` to fix these automatically') } - if errors.len > 0 { + if errors.len > 0 || (is_werror && warnings.len > 0) { exit(1) } } diff --git a/cmd/v/help/default.txt b/cmd/v/help/default.txt index a5e8f4e7dd..e5d838e75e 100644 --- a/cmd/v/help/default.txt +++ b/cmd/v/help/default.txt @@ -49,4 +49,4 @@ Use "v help " for more information about a command, example: `v help bu Use "v help other" to see less frequently used commands. Note: Help is required to write more help topics. -Only build, new, init, doc, fmt, run, test, search, install, remove, update, bin2v, check-md are properly documented currently. +Only build, new, init, doc, fmt, vet, run, test, search, install, remove, update, bin2v, check-md are properly documented currently. diff --git a/cmd/v/help/vet.txt b/cmd/v/help/vet.txt new file mode 100644 index 0000000000..813a0ab511 --- /dev/null +++ b/cmd/v/help/vet.txt @@ -0,0 +1,11 @@ +Usage: + v vet [options] path_to_source.v [path_to_other_source.v] + v vet [options] path/to/dir [path/to/other_dir] + +Reports suspicious code constructs. + +Options: + -W Exit with code 1, even if vet only reported warnings. Useful for checks in CI. + -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.