From 933f73b730d966194890977b68faf2b3f9505415 Mon Sep 17 00:00:00 2001 From: Tpt Date: Sun, 26 Feb 2023 20:42:08 +0100 Subject: [PATCH] Server: Load command: makes the "--file" option positional --- server/src/main.rs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/server/src/main.rs b/server/src/main.rs index 033a1819..ad3943f8 100644 --- a/server/src/main.rs +++ b/server/src/main.rs @@ -94,14 +94,16 @@ enum Command { /// If multiple files are provided they are loaded in parallel. /// /// If no file is given, stdin is read. - #[arg(short, long, global = true, num_args = 0..)] + #[arg(num_args = 0..)] file: Vec, + #[arg(short = 'f', long = "file", global = true, num_args = 0.., value_name = "FILE", hide = true)] + file_opt: Vec, //TODO: remove on next breaking release /// The format of the file(s) to load. /// /// Can be an extension like "nt" or a MIME type like "application/n-triples". /// /// By default the format is guessed from the loaded file extension. - #[arg(long, required_unless_present = "file")] + #[arg(long, required_unless_present_any = ["file", "file_opt"])] format: Option, /// Attempt to keep loading even if the data file is invalid. /// @@ -165,7 +167,8 @@ pub fn main() -> anyhow::Result<()> { false, ), Command::Load { - file, + mut file, + file_opt, location, lenient, format, @@ -177,7 +180,10 @@ pub fn main() -> anyhow::Result<()> { eprintln!("Warning: opening an in-memory store. It will not be possible to read the written data."); Store::new() }?; - + if !file_opt.is_empty() { + eprintln!("Warning: the --file option is deprecated. Please use a positional argument instead"); + file.extend(file_opt); + } let format = if let Some(format) = format { Some(GraphOrDatasetFormat::from_str(&format)?) } else { @@ -1357,7 +1363,6 @@ mod tests { .arg("load") .arg("--location") .arg(store_dir.path()) - .arg("-f") .arg(input_file.path()) .assert() .success(); @@ -1387,7 +1392,6 @@ mod tests { .arg("load") .arg("--location") .arg(store_dir.path()) - .arg("-f") .arg(input_file.path()) .assert() .success(); @@ -1414,7 +1418,6 @@ mod tests { file.write_binary(&encoder.finish()?)?; cli_command()? .arg("load") - .arg("-f") .arg(file.path()) .assert() .success(); @@ -1461,7 +1464,7 @@ mod tests { .write_str(" .")?; cli_command()? .arg("load") - .arg("--location") + .arg("-l") .arg(store_dir.path()) .arg("-f") .arg(input_file.path())