2 #[derive(Debug, 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 new() -> Summary {
20 has_operational_errors: false,
21 has_parsing_errors: false,
22 has_formatting_errors: false,
27 pub fn has_operational_errors(&self) -> bool {
28 self.has_operational_errors
31 pub fn has_parsing_errors(&self) -> bool {
32 self.has_parsing_errors
35 pub fn has_formatting_errors(&self) -> bool {
36 self.has_formatting_errors
39 pub fn add_operational_error(&mut self) {
40 self.has_operational_errors = true;
43 pub fn add_parsing_error(&mut self) {
44 self.has_parsing_errors = true;
47 pub fn add_formatting_error(&mut self) {
48 self.has_formatting_errors = true;
51 pub fn add_diff(&mut self) {
55 pub fn has_no_errors(&self) -> bool {
56 !(self.has_operational_errors || self.has_parsing_errors || self.has_formatting_errors ||
60 pub fn add(&mut self, other: Summary) {
61 self.has_operational_errors |= other.has_operational_errors;
62 self.has_formatting_errors |= other.has_formatting_errors;
63 self.has_parsing_errors |= other.has_parsing_errors;
64 self.has_diff |= other.has_diff;
67 pub fn print_exit_codes() {
68 let exit_codes = r#"Exit Codes:
70 1 = Encountered operational errors e.g. an IO error
71 2 = Failed to reformat code because of parsing errors
72 3 = Code is valid, but it is impossible to format it properly
73 4 = Formatted code differs from existing code (write-mode diff only)"#;
74 println!("{}", exit_codes);