WIP: allow using nff as a diagnostics source #1
					 1 changed files with 13 additions and 5 deletions
				
			
		lint: introduce LintError; count diagnostic errors
		
	
				commit
				
					
					
						8d7fcd6ef4
					
				
			
		
							
								
								
									
										18
									
								
								src/main.rs
									
										
									
									
									
								
							
							
						
						
									
										18
									
								
								src/main.rs
									
										
									
									
									
								
							|  | @ -38,6 +38,12 @@ enum FormatterError { | |||
|     Io(#[from] io::Error), | ||||
| } | ||||
| 
 | ||||
| #[derive(Error, Debug)] | ||||
| enum LintError { | ||||
|     #[error("Lint errors found in {file_count} file(s)")] | ||||
|     DiagnosticErrors { file_count: usize }, | ||||
| } | ||||
| 
 | ||||
| #[derive(Parser, Debug, Clone)] | ||||
| #[command(
 | ||||
|     name = "nff", | ||||
|  | @ -337,7 +343,7 @@ fn process_lint_command( | |||
|     }; | ||||
| 
 | ||||
|     let is_multiple_files = files.len() > 1; | ||||
|     let mut has_errors = false; | ||||
|     let mut error_file_count = 0; | ||||
| 
 | ||||
|     for file_path in files { | ||||
|         if let Err(e) = process_single_file_lint( | ||||
|  | @ -352,16 +358,18 @@ fn process_lint_command( | |||
|             is_multiple_files, | ||||
|         ) { | ||||
|             eprintln!("Error processing {}: {}", file_path, e); | ||||
|             has_errors = true; | ||||
|             error_file_count += 1; | ||||
|             if !is_multiple_files { | ||||
|                 return Err(e); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     // Exit with non-zero code if any file had errors
 | ||||
|     if has_errors { | ||||
|         std::process::exit(1); | ||||
|     if error_file_count > 0 { | ||||
|         return Err(LintError::DiagnosticErrors { | ||||
|             file_count: error_file_count, | ||||
|         } | ||||
|         .into()); | ||||
|     } | ||||
| 
 | ||||
|     Ok(()) | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue