Server: Load command: makes the "--file" option positional

pull/410/head
Tpt 2 years ago committed by Thomas Tanon
parent d42e2a818c
commit 6d4a15d067
  1. 19
      server/src/main.rs

@ -94,14 +94,16 @@ enum Command {
/// If multiple files are provided they are loaded in parallel. /// If multiple files are provided they are loaded in parallel.
/// ///
/// If no file is given, stdin is read. /// If no file is given, stdin is read.
#[arg(short, long, global = true, num_args = 0..)] #[arg(num_args = 0..)]
file: Vec<PathBuf>, file: Vec<PathBuf>,
#[arg(short = 'f', long = "file", global = true, num_args = 0.., value_name = "FILE", hide = true)]
file_opt: Vec<PathBuf>, //TODO: remove on next breaking release
/// The format of the file(s) to load. /// The format of the file(s) to load.
/// ///
/// Can be an extension like "nt" or a MIME type like "application/n-triples". /// 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. /// 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<String>, format: Option<String>,
/// Attempt to keep loading even if the data file is invalid. /// Attempt to keep loading even if the data file is invalid.
/// ///
@ -165,7 +167,8 @@ pub fn main() -> anyhow::Result<()> {
false, false,
), ),
Command::Load { Command::Load {
file, mut file,
file_opt,
location, location,
lenient, lenient,
format, 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."); eprintln!("Warning: opening an in-memory store. It will not be possible to read the written data.");
Store::new() 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 { let format = if let Some(format) = format {
Some(GraphOrDatasetFormat::from_str(&format)?) Some(GraphOrDatasetFormat::from_str(&format)?)
} else { } else {
@ -1357,7 +1363,6 @@ mod tests {
.arg("load") .arg("load")
.arg("--location") .arg("--location")
.arg(store_dir.path()) .arg(store_dir.path())
.arg("-f")
.arg(input_file.path()) .arg(input_file.path())
.assert() .assert()
.success(); .success();
@ -1387,7 +1392,6 @@ mod tests {
.arg("load") .arg("load")
.arg("--location") .arg("--location")
.arg(store_dir.path()) .arg(store_dir.path())
.arg("-f")
.arg(input_file.path()) .arg(input_file.path())
.assert() .assert()
.success(); .success();
@ -1414,7 +1418,6 @@ mod tests {
file.write_binary(&encoder.finish()?)?; file.write_binary(&encoder.finish()?)?;
cli_command()? cli_command()?
.arg("load") .arg("load")
.arg("-f")
.arg(file.path()) .arg(file.path())
.assert() .assert()
.success(); .success();
@ -1461,7 +1464,7 @@ mod tests {
.write_str("<http://example.com/s> <http://example.com/p> <http://example.com/o> .")?; .write_str("<http://example.com/s> <http://example.com/p> <http://example.com/o> .")?;
cli_command()? cli_command()?
.arg("load") .arg("load")
.arg("--location") .arg("-l")
.arg(store_dir.path()) .arg(store_dir.path())
.arg("-f") .arg("-f")
.arg(input_file.path()) .arg(input_file.path())

Loading…
Cancel
Save