|
|
@ -223,11 +223,44 @@ pub type Output = HashSet<Argument>;
|
|
|
|
"If this was intended as a path instead of an option, use option `-` before it."
|
|
|
|
"If this was intended as a path instead of an option, use option `-` before it."
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn parse_single<I>(args: &mut I, output: &mut Output, this: char) -> eyre::Result<Continue>
|
|
|
|
fn save_output(output: &mut Output, item: Argument) -> eyre::Result<()>
|
|
|
|
where I: Iterator<Item=String>
|
|
|
|
{
|
|
|
|
|
|
|
|
if let Some(mx) = output.iter().filter(|arg| item.is_mx_with(arg)).next() {
|
|
|
|
|
|
|
|
return Err(eyre!("Arguments are mutually exclusive"))
|
|
|
|
|
|
|
|
.with_section(|| item.header("Trying to add"))
|
|
|
|
|
|
|
|
.with_section(|| mx.to_string().header("Which is mutually exclusive with"));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
output.insert(item); //TODO: Warn when adding duplicate?
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn parse_single<I>(_args: &mut I, output: &mut Output, this: char) -> eyre::Result<Continue>
|
|
|
|
|
|
|
|
where I: Iterator<Item=String>
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
let item = match this
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//TODO: Parse single letter args
|
|
|
|
'r' => Argument::UnlimitRecurse,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[cfg(feature="inspect")] 'D' => Argument::SaveStdout,
|
|
|
|
|
|
|
|
#[cfg(feature="inspect")] 'R' => Argument::SaveRawStdout,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
'v' => Argument::LogVerbose,
|
|
|
|
|
|
|
|
'q' => Argument::LogQuiet,
|
|
|
|
|
|
|
|
'Q' => Argument::LogSilent,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
'm' => Argument::LimitConcMaxProc,
|
|
|
|
|
|
|
|
'M' => Argument::UnlimitConc,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
unknown => {
|
|
|
|
|
|
|
|
return Err(eyre!("Unknown short argument {:?}", unknown))
|
|
|
|
|
|
|
|
.with_suggestion(suggestion_intended_arg.clone());
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
save_output(output, item)?;
|
|
|
|
|
|
|
|
|
|
|
|
Ok(Continue::Yes)
|
|
|
|
Ok(Continue::Yes)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -256,7 +289,18 @@ where I: Iterator<Item=String>
|
|
|
|
"-" => {
|
|
|
|
"-" => {
|
|
|
|
return Ok(Continue::No);
|
|
|
|
return Ok(Continue::No);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
//TODO: move rest of long args from `mod` to here
|
|
|
|
#[cfg(feature="inspect")] "--save" => {
|
|
|
|
|
|
|
|
let file = args.next().ok_or(eyre!("`--save` expects a parameter"))
|
|
|
|
|
|
|
|
.with_suggestion(suggestion_intended_arg.clone())?;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Argument::Save(file)
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
#[cfg(feature="inspect")] "--save-raw" => {
|
|
|
|
|
|
|
|
let file = args.next().ok_or(eyre!("`--save` expects a parameter"))
|
|
|
|
|
|
|
|
.with_suggestion(suggestion_intended_arg.clone())?;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Argument::SaveRaw(file)
|
|
|
|
|
|
|
|
},
|
|
|
|
single if single.starts_with("-") => {
|
|
|
|
single if single.starts_with("-") => {
|
|
|
|
for ch in single.chars().skip(1) {
|
|
|
|
for ch in single.chars().skip(1) {
|
|
|
|
match parse_single(args, output, ch)? {
|
|
|
|
match parse_single(args, output, ch)? {
|
|
|
@ -274,13 +318,7 @@ where I: Iterator<Item=String>
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
if let Some(mx) = output.iter().filter(|arg| item.is_mx_with(arg)).next() {
|
|
|
|
save_output(output, item)?;
|
|
|
|
return Err(eyre!("Arguments are mutually exclusive"))
|
|
|
|
|
|
|
|
.with_section(|| item.header("Trying to add"))
|
|
|
|
|
|
|
|
.with_section(|| mx.to_string().header("Which is mutually exclusive with"));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
output.insert(item); //TODO: Warn when adding duplicate?
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Ok(keep_reading)
|
|
|
|
Ok(keep_reading)
|
|
|
|
}
|
|
|
|
}
|
|
|
|