From a68b4f520d31a55bbcf87ba8dd90d0f86b595cdc Mon Sep 17 00:00:00 2001 From: jaby Date: Fri, 11 Nov 2022 15:54:35 +0100 Subject: [PATCH] Extend batch file to use run commands --- src/Tools/Tools.code-workspace | 12 ++++++++++++ src/Tools/psxcdgen_ex/src/main.rs | 22 +++++++++++++++++++++- src/Tools/run_cargo.bat | 4 +++- 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/src/Tools/Tools.code-workspace b/src/Tools/Tools.code-workspace index fe8c0f56..cb999dea 100644 --- a/src/Tools/Tools.code-workspace +++ b/src/Tools/Tools.code-workspace @@ -22,6 +22,11 @@ "command": "./run_cargo ${input:project} ${input:cargo cmd} ${input:build cfg} ${input:cargo target}", "group": { "kind": "build", + }, + "options": { + "env": { + "CARGO_RUN_ARGS": "${input:cargo run args}" + } } }, { @@ -69,6 +74,13 @@ "type": "pickString", "options": ["windows", "linux"], "description": "The target for the tool to build" + }, + { + "id": "cargo run args", + "type": "pickString", + "options": ["", "--help"], + "default": "", + "description": "Argument options to pass to cargo run" } ] } diff --git a/src/Tools/psxcdgen_ex/src/main.rs b/src/Tools/psxcdgen_ex/src/main.rs index 4139cff7..5e02d56b 100644 --- a/src/Tools/psxcdgen_ex/src/main.rs +++ b/src/Tools/psxcdgen_ex/src/main.rs @@ -1,4 +1,4 @@ -use clap::{Parser, Subcommand}; +use clap::{Parser, ValueEnum}; 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; @@ -6,7 +6,27 @@ use tool_helper::Error; #[derive(Parser)] #[clap(about = "Creates an ISO image from a description file", long_about = None)] struct CommandLine { + #[clap(value_enum, value_parser)] + system_type: SystemType, + #[clap(value_enum, value_parser, default_value_t=OutputType::BinCue)] + output_type: OutputType, + + #[clap(short='o')] + output_file: PathBuf, + + #[clap(value_parser)] + input_file: PathBuf, +} + +#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, ValueEnum)] +enum SystemType { + Psx +} + +#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, ValueEnum)] +enum OutputType { + BinCue } fn run_main() -> Result<(), Error> { diff --git a/src/Tools/run_cargo.bat b/src/Tools/run_cargo.bat index 05d886a6..89b70c5a 100644 --- a/src/Tools/run_cargo.bat +++ b/src/Tools/run_cargo.bat @@ -11,6 +11,8 @@ IF %4 == linux ( set target=x86_64-unknown-linux-musl ) +IF defined CARGO_RUN_ARGS set run_args=-- %CARGO_RUN_ARGS% + IF %2 == build set run_build=1 IF %2 == test set run_build=1 @@ -28,7 +30,7 @@ IF defined run_build ( IF %2 == run ( echo cargo run %1 --%3 - cargo run --%3 --target=%target% + cargo run --%3 --target=%target% %run_args% exit /B %ERRORLEVEL% )