2 #[derive(Debug, Default, Clone)]
4 // Encountered e.g. an IO error.
5 has_operational_errors: bool,
7 // Failed to reformat code because of parsing errors.
8 has_parsing_errors: bool,
10 // Code is valid, but it is impossible to format it properly.
11 has_formatting_errors: bool,
13 // Formatted code differs from existing code (write-mode diff only).
18 pub fn has_operational_errors(&self) -> bool {
19 self.has_operational_errors
22 pub fn has_parsing_errors(&self) -> bool {
23 self.has_parsing_errors
26 pub fn has_formatting_errors(&self) -> bool {
27 self.has_formatting_errors
30 pub fn add_operational_error(&mut self) {
31 self.has_operational_errors = true;
34 pub fn add_parsing_error(&mut self) {
35 self.has_parsing_errors = true;
38 pub fn add_formatting_error(&mut self) {
39 self.has_formatting_errors = true;
42 pub fn add_diff(&mut self) {
46 pub fn has_no_errors(&self) -> bool {
47 !(self.has_operational_errors || self.has_parsing_errors || self.has_formatting_errors
51 pub fn add(&mut self, other: Summary) {
52 self.has_operational_errors |= other.has_operational_errors;
53 self.has_formatting_errors |= other.has_formatting_errors;
54 self.has_parsing_errors |= other.has_parsing_errors;
55 self.has_diff |= other.has_diff;
58 pub fn print_exit_codes() {
59 let exit_codes = r#"Exit Codes:
61 1 = Encountered operational errors e.g. an IO error
62 2 = Failed to reformat code because of parsing errors
63 3 = Code is valid, but it is impossible to format it properly
64 4 = Formatted code differs from existing code (write-mode diff only)"#;
65 println!("{}", exit_codes);