vfmt: enable colored warnings/errors (#8527)

pull/8530/head
Lukas Neubert 2021-02-03 09:03:41 +01:00 committed by GitHub
parent df0520b43a
commit 3ef4885094
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 1 deletions

View File

@ -6,6 +6,7 @@ module main
import os import os
import os.cmdline import os.cmdline
import rand import rand
import term
import v.ast import v.ast
import v.pref import v.pref
import v.fmt import v.fmt
@ -30,6 +31,7 @@ struct FormatOptions {
const ( const (
formatted_file_token = '\@\@\@' + 'FORMATTED_FILE: ' formatted_file_token = '\@\@\@' + 'FORMATTED_FILE: '
vtmp_folder = util.get_vtmp_folder() vtmp_folder = util.get_vtmp_folder()
term_colors = term.can_show_color_on_stderr()
) )
fn main() { fn main() {
@ -52,6 +54,9 @@ fn main() {
is_noerror: '-noerror' in args is_noerror: '-noerror' in args
is_verify: '-verify' in args is_verify: '-verify' in args
} }
if term_colors {
os.setenv('VCOLORS', 'always', true)
}
if foptions.is_verbose { if foptions.is_verbose {
eprintln('vfmt foptions: $foptions') eprintln('vfmt foptions: $foptions')
} }
@ -271,7 +276,7 @@ fn (foptions &FormatOptions) post_process_file(file string, formatted_file_path
} }
fn (f FormatOptions) str() string { fn (f FormatOptions) str() string {
return return
'FormatOptions{ is_l: $f.is_l, is_w: $f.is_w, is_diff: $f.is_diff, is_verbose: $f.is_verbose,' + 'FormatOptions{ is_l: $f.is_l, is_w: $f.is_w, is_diff: $f.is_diff, is_verbose: $f.is_verbose,' +
' is_all: $f.is_all, is_worker: $f.is_worker, is_debug: $f.is_debug, is_noerror: $f.is_noerror,' + ' is_all: $f.is_all, is_worker: $f.is_worker, is_debug: $f.is_debug, is_noerror: $f.is_noerror,' +
' is_verify: $f.is_verify" }' ' is_verify: $f.is_verify" }'