@@ -44,6 +44,11 @@ struct Args {
4444
4545 #[ arg( long) ]
4646 output : Option < String > ,
47+
48+ /// When set, validation errors are printed as warnings and the tool exits
49+ /// with code 0. Intended for use during development (maturity=development).
50+ #[ arg( long, default_value_t = false ) ]
51+ warn_on_errors : bool ,
4752}
4853
4954struct ValidationCliInputs {
@@ -95,7 +100,12 @@ fn run(args: Args) -> Result<(), String> {
95100 let mut context = build_validation_context ( inputs) ?;
96101 let validators = resolve_validators ( & context) ?;
97102
98- run_selected_validators ( args. output . as_deref ( ) , & validators, & mut context)
103+ run_selected_validators (
104+ args. output . as_deref ( ) ,
105+ args. warn_on_errors ,
106+ & validators,
107+ & mut context,
108+ )
99109}
100110
101111fn resolve_validators ( context : & ValidationContext ) -> Result < Vec < SelectedValidator > , String > {
@@ -117,6 +127,7 @@ fn resolve_validators(context: &ValidationContext) -> Result<Vec<SelectedValidat
117127
118128fn run_selected_validators (
119129 output_path : Option < & str > ,
130+ warn_on_errors : bool ,
120131 validators : & [ SelectedValidator ] ,
121132 context : & mut ValidationContext ,
122133) -> Result < ( ) , String > {
@@ -126,7 +137,7 @@ fn run_selected_validators(
126137 merge_errors ( & mut errors, run_validator ( * validator, context) ) ;
127138 }
128139
129- finish_validation ( output_path, & errors)
140+ finish_validation ( output_path, warn_on_errors , & errors)
130141}
131142
132143fn run_validator ( validator : SelectedValidator , context : & ValidationContext ) -> Errors {
@@ -195,7 +206,11 @@ fn merge_errors(target: &mut Errors, incoming: Errors) {
195206 }
196207}
197208
198- fn finish_validation ( output_path : Option < & str > , errors : & Errors ) -> Result < ( ) , String > {
209+ fn finish_validation (
210+ output_path : Option < & str > ,
211+ warn_on_errors : bool ,
212+ errors : & Errors ,
213+ ) -> Result < ( ) , String > {
199214 if let Some ( path) = output_path {
200215 write_log ( path, errors) ?;
201216 }
@@ -215,7 +230,12 @@ fn finish_validation(output_path: Option<&str>, errors: &Errors) -> Result<(), S
215230 errors. messages. len( ) ,
216231 details
217232 ) ;
218- Err ( output)
233+ if warn_on_errors {
234+ eprintln ! ( "WARNING: {output}" ) ;
235+ Ok ( ( ) )
236+ } else {
237+ Err ( output)
238+ }
219239 }
220240}
221241
0 commit comments