Skip to content

Commit 316f662

Browse files
committed
feat: add -o,--output flag to change output directory
1 parent 15aad25 commit 316f662

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/main.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ pub struct PackageArgs {
5454
#[arg(long, short = 'F', value_name = "FEATURES")]
5555
features: Option<Vec<String>>,
5656

57+
/// Where to save the generated package.
58+
#[arg(long, short, value_name = "PATH")]
59+
output: Option<String>,
60+
5761
/// Whether to skip the build.
5862
#[arg(long, action = clap::ArgAction::SetTrue)]
5963
no_build: bool,
@@ -197,19 +201,26 @@ fn main() -> anyhow::Result<()> {
197201
OutputFormat::Ipk => "ipk",
198202
OutputFormat::Rpm => "rpm",
199203
};
204+
let target = if let Some(output) = &args.output {
205+
output.clone()
206+
} else {
207+
tmpdir.to_string()
208+
};
200209
let mut cmd = Command::new(nfpm_bin);
201210
cmd.arg("package")
202211
.arg("--config")
203212
.arg(config_path)
204213
.arg("--packager")
205214
.arg(packager)
206215
.arg("--target")
207-
.arg(tmpdir);
216+
.arg(target);
208217

209218
let res = cmd.status().context("running nfpm")?;
210219
if res.success() {
211220
return Ok(());
212221
}
213222

214-
Err(anyhow::anyhow!("failed to build package"))
223+
Err(anyhow::anyhow!(
224+
"failed to build package. check stdout/stderr"
225+
))
215226
}

0 commit comments

Comments
 (0)