Skip to content

Commit

Permalink
fix(cli): PathBuf parsing for CLI args (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
DonIsaac authored Sep 18, 2024
1 parent ed41f25 commit 2754ecd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
10 changes: 8 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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)
Expand Down
7 changes: 7 additions & 0 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -23,13 +24,15 @@ 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(
Arg::new("tsconfig")
.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.
Expand All @@ -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<PathBuf> {
Ok(PathBuf::from(v))
}

#[non_exhaustive]
pub struct CliOptions {
pub root: Root,
Expand Down

0 comments on commit 2754ecd

Please sign in to comment.