Prepare convert function

This commit is contained in:
2022-09-13 21:19:42 +02:00
parent e42b3ab6cf
commit 4b69d678e8
4 changed files with 23 additions and 15 deletions

View File

@@ -1,8 +1,6 @@
#[cfg(test)]
mod tests {
#[test]
fn it_works() {
let result = 2 + 2;
assert_eq!(result, 4);
}
}
use tool_helper::{Input, Output, Result};
pub use tool_helper::Error;
pub fn convert(_input: Input, _output: Output) -> Result<()> {
Err(Error::new(-1, "Not implemented yet".to_owned()))
}

View File

@@ -14,8 +14,10 @@ struct CommandLine {
fn run_main() -> tool_helper::Result<()> {
match CommandLine::try_parse() {
Ok(cmd) => {
let _output = tool_helper::open_output(cmd.input_file)?;
return Ok(());
let input = tool_helper::open_input(cmd.input_file)?;
let output = tool_helper::open_output(Some(cmd.output_file))?;
return cpp_out::convert(input, output);
},
Err(error) => Err(tool_helper::Error::new(-1, error.to_string()))
}
@@ -23,7 +25,7 @@ fn run_main() -> tool_helper::Result<()> {
fn main() {
match run_main() {
Ok(_) => println!("All good"),
Ok(_) => (),
Err(error) => {
eprintln!("{}", error.text);
std::process::exit(error.exit_code);