From bdf0d82ced81fbf65b8d90cf26ff78495173c9d3 Mon Sep 17 00:00:00 2001 From: Christian Ebner Date: Tue, 16 Jul 2019 15:45:17 +0200 Subject: [PATCH] src/bin/pxar.rs: Make pxar extract target optional In order to improve usablity, the target on archive extraction will be the current working directory by default. A different target can be provided via the optional --target parameter. Signed-off-by: Christian Ebner --- src/bin/pxar.rs | 6 +++--- tests/pxar.rs | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/bin/pxar.rs b/src/bin/pxar.rs index 1ba81d58..ccdf4ab5 100644 --- a/src/bin/pxar.rs +++ b/src/bin/pxar.rs @@ -77,7 +77,7 @@ fn extract_archive( ) -> Result { let archive = tools::required_string_param(¶m, "archive")?; - let target = tools::required_string_param(¶m, "target")?; + let target = param["target"].as_str().unwrap_or("."); let verbose = param["verbose"].as_bool().unwrap_or(false); let no_xattrs = param["no-xattrs"].as_bool().unwrap_or(false); let no_fcaps = param["no-fcaps"].as_bool().unwrap_or(false); @@ -177,13 +177,13 @@ fn main() { extract_archive, ObjectSchema::new("Extract an archive.") .required("archive", StringSchema::new("Archive name.")) - .required("target", StringSchema::new("Target directory.")) + .optional("target", StringSchema::new("Target directory.")) .optional("verbose", BooleanSchema::new("Verbose output.").default(false)) .optional("no-xattrs", BooleanSchema::new("Ignore extended file attributes.").default(false)) .optional("no-fcaps", BooleanSchema::new("Ignore file capabilities.").default(false)) .optional("no-acls", BooleanSchema::new("Ignore access control list entries.").default(false)) )) - .arg_param(vec!["archive", "target"]) + .arg_param(vec!["archive"]) .completion_cb("archive", tools::complete_file_name) .completion_cb("target", tools::complete_file_name) .into() diff --git a/tests/pxar.rs b/tests/pxar.rs index 8e66a4c9..e2f0a211 100644 --- a/tests/pxar.rs +++ b/tests/pxar.rs @@ -27,6 +27,7 @@ fn pxar_create_and_extract() { Command::new(exec_path) .arg("extract") .arg("./tests/archive.pxar") + .arg("--target") .arg(dest_dir) .status() .unwrap_or_else(|err| {