From f0133e688a65d2618e0af6e6633fa944f7f791eb Mon Sep 17 00:00:00 2001 From: Jaby Date: Wed, 9 Nov 2022 23:11:30 +0100 Subject: [PATCH] Add clap --- src/Tools/psxcdgen_ex/Cargo.toml | 1 + src/Tools/psxcdgen_ex/src/main.rs | 20 +++++++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/Tools/psxcdgen_ex/Cargo.toml b/src/Tools/psxcdgen_ex/Cargo.toml index ea41679e..f17a6680 100644 --- a/src/Tools/psxcdgen_ex/Cargo.toml +++ b/src/Tools/psxcdgen_ex/Cargo.toml @@ -7,6 +7,7 @@ edition = "2021" [dependencies] cdtypes = {path = "../cdtypes"} +clap = {version = "*", features = ["derive"]} paste = "*" roxmltree = "*" tool_helper = {path = "../tool_helper"} \ No newline at end of file diff --git a/src/Tools/psxcdgen_ex/src/main.rs b/src/Tools/psxcdgen_ex/src/main.rs index 8a685f14..4139cff7 100644 --- a/src/Tools/psxcdgen_ex/src/main.rs +++ b/src/Tools/psxcdgen_ex/src/main.rs @@ -1,7 +1,14 @@ +use clap::{Parser, Subcommand}; use psxcdgen_ex::{encoder::psx::{encode_psx_image, calculate_psx_lbas}, file_writer::{ImageType, write_image}, types::{layout::Layout}, config_reader}; use std::{path::PathBuf, str::FromStr}; use tool_helper::Error; +#[derive(Parser)] +#[clap(about = "Creates an ISO image from a description file", long_about = None)] +struct CommandLine { + +} + fn run_main() -> Result<(), Error> { let desc = psxcdgen_ex::process(config_reader::parse_xml(std::fs::read_to_string("../Tests/ISO_Planschbecken.xml")?)?, calculate_psx_lbas)?; @@ -25,8 +32,15 @@ fn run_main() -> Result<(), Error> { } fn main() { - match run_main() { - Ok(_) => println!("\n<== Planschbecken End ==>"), - Err(error) => println!("{}", error) + match CommandLine::try_parse() { + Ok(_) => { + match run_main() { + Ok(_) => println!("\n<== Planschbecken End ==>"), + Err(error) => println!("{}", error) + } + }, + Err(error) => { + println!("{}", error); + } } } \ No newline at end of file