Start hacking checkstyle output in.

checkstyle now shows up on the option parser, and the code still
compiles/passes tests. Next up will be outputing the XML to stdout.
This commit is contained in:
Mark Story 2015-12-27 23:13:32 -05:00
parent 3f7741bb0c
commit 0c9f27fe5e
3 changed files with 17 additions and 1 deletions

View file

@ -90,7 +90,7 @@ fn execute() -> i32 {
opts.optopt("", opts.optopt("",
"write-mode", "write-mode",
"mode to write in (not usable when piping from stdin)", "mode to write in (not usable when piping from stdin)",
"[replace|overwrite|display|diff|coverage]"); "[replace|overwrite|display|diff|coverage|checkstyle]");
opts.optflag("", "skip-children", "don't reformat child modules"); opts.optflag("", "skip-children", "don't reformat child modules");
opts.optflag("", opts.optflag("",

View file

@ -136,6 +136,8 @@ configuration_option_enum! { WriteMode:
Coverage, Coverage,
// Unfancy stdout // Unfancy stdout
Plain, Plain,
// Output a checkstyle XML file.
Checkstyle,
} }
// This trait and the following impl blocks are there so that we an use // This trait and the following impl blocks are there so that we an use

View file

@ -38,6 +38,7 @@ pub fn write_all_files(file_map: &FileMap,
try!(write_file(&file_map[filename], filename, mode, config)); try!(write_file(&file_map[filename], filename, mode, config));
} }
// Output trailers for write mode.
Ok(()) Ok(())
} }
@ -142,6 +143,19 @@ pub fn write_file(text: &StringBuffer,
WriteMode::Default => { WriteMode::Default => {
unreachable!("The WriteMode should NEVER Be default at this point!"); unreachable!("The WriteMode should NEVER Be default at this point!");
} }
WriteMode::Checkstyle => {
// Generate the diff for the current file.
// Output the XML tags for the lines that are different.
// Use the new text as 'should be X'.
}
WriteMode::Return => {
// io::Write is not implemented for String, working around with
// Vec<u8>
let mut v = Vec::new();
try!(write_system_newlines(&mut v, text, config));
// won't panic, we are writing correct utf8
return Ok(Some(String::from_utf8(v).unwrap()));
}
} }
Ok(None) Ok(None)