From c8d572ba56a37edc3b9cf6291f8fdbcb51b51f5b Mon Sep 17 00:00:00 2001 From: Jaby Date: Sun, 30 Apr 2023 15:33:32 +0200 Subject: [PATCH] Do not display the help in red for fconv --- src/Tools/jaby_engine_fconv/src/main.rs | 71 ++++++++++++------------- 1 file changed, 33 insertions(+), 38 deletions(-) diff --git a/src/Tools/jaby_engine_fconv/src/main.rs b/src/Tools/jaby_engine_fconv/src/main.rs index 10b3e819..8605bc01 100644 --- a/src/Tools/jaby_engine_fconv/src/main.rs +++ b/src/Tools/jaby_engine_fconv/src/main.rs @@ -25,50 +25,45 @@ enum SubCommands { SimpleTIM(reduced_tim::Arguments) } -fn run_main() -> Result<(), Error> { - match CommandLine::try_parse() { - Ok(cmd) => { - let mut input = tool_helper::open_input(cmd.input_file)?; - let mut buffer = Vec::::new(); - let mut output_file = tool_helper::open_output(cmd.output_file)?; - let dst_buffer = { - if cmd.compress_lz4 { - &mut buffer as &mut dyn std::io::Write - } +fn run_main(cmd: CommandLine) -> Result<(), Error> { + let mut input = tool_helper::open_input(cmd.input_file)?; + let mut buffer = Vec::::new(); + let mut output_file = tool_helper::open_output(cmd.output_file)?; + let dst_buffer = { + if cmd.compress_lz4 { + &mut buffer as &mut dyn std::io::Write + } - else { - &mut output_file as &mut dyn std::io::Write - } - }; + else { + &mut output_file as &mut dyn std::io::Write + } + }; - match cmd.sub_command { - SubCommands::Nothing => { - std::io::copy(&mut input, dst_buffer)?; - }, - SubCommands::SimpleTIM(args) => { - reduced_tim::convert(args, input, dst_buffer)?; - } - } - - // We encoded the file to a temporary buffer and now need to write it - if cmd.compress_lz4 { - let buffer = tool_helper::compress::psx_default::lz4(&buffer)?; - output_file.write(&buffer)?; - } - - Ok(()) + match cmd.sub_command { + SubCommands::Nothing => { + std::io::copy(&mut input, dst_buffer)?; }, - Err(error) => Err({ - let mut error = Error::from_error(error); + SubCommands::SimpleTIM(args) => { + reduced_tim::convert(args, input, dst_buffer)?; + } + } - error.exit_code = 0; - error - }) - } + // We encoded the file to a temporary buffer and now need to write it + if cmd.compress_lz4 { + let buffer = tool_helper::compress::psx_default::lz4(&buffer)?; + output_file.write(&buffer)?; + } + + Ok(()) } fn main() { - if let Err(error) = run_main() { - exit_with_error(error); + match CommandLine::try_parse() { + Ok(cmd) => { + if let Err(error) = run_main(cmd) { + exit_with_error(error); + } + }, + Err(error) => eprintln!("{}", error) } } \ No newline at end of file