@@ -49,6 +49,7 @@ const Configuration = struct {
49
49
check_format : ? bool = null ,
50
50
enforce_const_pointers : ? bool = null ,
51
51
include_gitignored : ? bool = null ,
52
+ verbose : ? bool = null ,
52
53
exclude : ? [][]const u8 = null ,
53
54
include : ? [][]const u8 = null ,
54
55
@@ -89,6 +90,9 @@ fn show_help() !void {
89
90
\\ to view this help message again: ziglint help
90
91
\\
91
92
\\options:
93
+ \\ --verbose
94
+ \\ print more information about what ziglint is doing
95
+ \\
92
96
\\ --max-line-length <u32>
93
97
\\ set the maximum length of a line of code
94
98
\\
@@ -193,6 +197,8 @@ pub fn main() anyerror!void {
193
197
switches .enforce_const_pointers = true ;
194
198
} else if (std .mem .eql (u8 , switch_name , "include-gitignored" )) {
195
199
switches .include_gitignored = true ;
200
+ } else if (std .mem .eql (u8 , switch_name , "verbose" )) {
201
+ switches .verbose = true ;
196
202
} else if (is_include or is_exclude ) {
197
203
args_idx += 1 ;
198
204
if (args_idx >= args .len ) {
@@ -240,7 +246,7 @@ pub fn main() anyerror!void {
240
246
const files = if (cmd_line_files .items .len > 0 ) cmd_line_files .items else &[_ ][]const u8 {"." };
241
247
var fault_count : u64 = 0 ;
242
248
for (files ) | file | {
243
- var config_file_parsed = try get_config (file , arena_allocator );
249
+ var config_file_parsed = try get_config (file , arena_allocator , switches . verbose orelse false );
244
250
var config = switches ;
245
251
246
252
if (config_file_parsed ) | c | {
@@ -264,7 +270,7 @@ pub fn main() anyerror!void {
264
270
if (config .include_gitignored != false ) {
265
271
const gitignore_path = try find_file (arena_allocator , file , ".gitignore" );
266
272
if (gitignore_path ) | path | {
267
- try stderr_print ("using Gitignore {s}" , .{path });
273
+ if ( config . verbose orelse false ) try stderr_print ("using Gitignore {s}" , .{path });
268
274
269
275
gitignore_text = try std .fs .cwd ().readFileAlloc (arena_allocator , path , MAX_CONFIG_BYTES );
270
276
try ignore_tracker .parse_gitignore (gitignore_text .? );
@@ -283,12 +289,12 @@ pub fn main() anyerror!void {
283
289
}
284
290
285
291
// Creates a Configuration object for the given file based on the nearest ziglintrc file.
286
- fn get_config (file_name : []const u8 , alloc : std.mem.Allocator ) ! ? std .json .Parsed (Configuration ) {
292
+ fn get_config (file_name : []const u8 , alloc : std.mem.Allocator , verbose : bool ) ! ? std .json .Parsed (Configuration ) {
287
293
const ziglintrc_path = try find_file (alloc , file_name , "ziglint.json" );
288
294
if (ziglintrc_path ) | path | {
289
295
defer alloc .free (path );
290
296
291
- try stderr_print ("using config file {s}" , .{path });
297
+ if ( verbose ) try stderr_print ("using config file {s}" , .{path });
292
298
const config_raw = try std .fs .cwd ().readFileAlloc (alloc , path , MAX_CONFIG_BYTES );
293
299
const cfg = std .json .parseFromSlice (Configuration , alloc , config_raw , .{}) catch | err | err_handle_blk : {
294
300
switch (err ) {
@@ -312,7 +318,7 @@ fn get_config(file_name: []const u8, alloc: std.mem.Allocator) !?std.json.Parsed
312
318
if (cfg != null ) return cfg ;
313
319
}
314
320
315
- try stderr_print ("warning: no valid ziglint.json found! using default configuration." , .{});
321
+ if ( verbose ) try stderr_print ("warning: no valid ziglint.json found! using default configuration." , .{});
316
322
return null ;
317
323
}
318
324
0 commit comments