Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cli): PathBuf parsing for CLI args #25

Merged
merged 1 commit into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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