From 2754ecdc26d395f1d59c4d4f1897a4db2c28a1e2 Mon Sep 17 00:00:00 2001 From: Don Isaac Date: Wed, 18 Sep 2024 17:42:08 -0400 Subject: [PATCH] fix(cli): PathBuf parsing for CLI args (#25) --- Cargo.toml | 10 ++++++++-- src/cli.rs | 7 +++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index f89ea61..4f9c682 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -55,7 +55,7 @@ panic = "abort" # The profile that 'cargo dist' will build with [profile.dist] inherits = "release" -lto = "thin" +lto = "thin" # Config for 'cargo dist' [workspace.metadata.dist] @@ -66,7 +66,13 @@ ci = "github" # The installers to generate for each app installers = ["shell", "powershell", "npm"] # Target platforms to build apps for (Rust target-triple syntax) -targets = ["aarch64-apple-darwin", "x86_64-apple-darwin", "x86_64-unknown-linux-gnu", "x86_64-unknown-linux-musl", "x86_64-pc-windows-msvc"] +targets = [ + "aarch64-apple-darwin", + "x86_64-apple-darwin", + "x86_64-unknown-linux-gnu", + "x86_64-unknown-linux-musl", + "x86_64-pc-windows-msvc", +] # The archive format to use for windows builds (defaults .zip) windows-archive = ".tar.gz" # The archive format to use for non-windows builds (defaults .tar.xz) diff --git a/src/cli.rs b/src/cli.rs index a200a14..1dc1301 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -13,6 +13,7 @@ pub fn cli() -> ArgMatches { .arg( Arg::new("root") .value_hint(ValueHint::DirPath) + .value_parser(path_parser) .help("Path to the root directory of your project") .long_help("Path to the root directory of your project. @@ -23,6 +24,7 @@ By default, oxbuild will look for the nearest package.json starting at your CWD .short('c') .long("config") .value_hint(ValueHint::FilePath) + .value_parser(path_parser) .help("Path to .oxbuildrc. Not yet supported"), ) .arg( @@ -30,6 +32,7 @@ By default, oxbuild will look for the nearest package.json starting at your CWD .short('p') // same as tsc .long("tsconfig") .value_hint(ValueHint::FilePath) + .value_parser(path_parser) .help("Path to tsconfig.json") .long_help("Path to tsconfig.json. @@ -46,6 +49,10 @@ By default, Oxbuild will look for a tsconfig.json next to the nearest package.js .get_matches() } +fn path_parser(v: &str) -> Result { + Ok(PathBuf::from(v)) +} + #[non_exhaustive] pub struct CliOptions { pub root: Root,