|
|
|
@ -37,6 +37,12 @@ pub fn usage() -> !
|
|
|
|
|
println!(" --cancel -w\t\tAlias for `--error-mode CANCEL`");
|
|
|
|
|
println!(" --error -W\t\tAlias for `--error-mode TERMINATE`");
|
|
|
|
|
println!(" --recurse <max>|inf\tRecursive mode, give max depth or infinite.");
|
|
|
|
|
#[cfg(feature="threads")]
|
|
|
|
|
println!(" --threads <max>|inf\tMax number of threads to run at once.");
|
|
|
|
|
#[cfg(feature="threads")]
|
|
|
|
|
println!(" -U\t\tUlimited max threads.");
|
|
|
|
|
#[cfg(feature="threads")]
|
|
|
|
|
println!(" --sync -S\t\tRun only one file at a time.");
|
|
|
|
|
println!(" --\t\t\tStop reading args");
|
|
|
|
|
println!("Other:");
|
|
|
|
|
println!(" --help -h:\t\tPrint this message");
|
|
|
|
@ -120,6 +126,9 @@ where I: IntoIterator<Item=String>
|
|
|
|
|
Ok(config::Rebase{
|
|
|
|
|
save: files.clone(), //TODO: Seperate save+loads
|
|
|
|
|
load: files,
|
|
|
|
|
|
|
|
|
|
#[cfg(feature="threads")]
|
|
|
|
|
max_threads: config::MAX_THREADS,
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -137,6 +146,9 @@ where I: IntoIterator<Item=String>
|
|
|
|
|
let mut mode_er = error::Mode::Cancel;
|
|
|
|
|
let mut mode_rec = config::RecursionMode::None;
|
|
|
|
|
let mut mode_log = log::Mode::Warn;
|
|
|
|
|
|
|
|
|
|
#[cfg(feature="threads")]
|
|
|
|
|
let mut threads = config::MAX_THREADS;
|
|
|
|
|
|
|
|
|
|
macro_rules! push {
|
|
|
|
|
($arg:expr) => {
|
|
|
|
@ -166,7 +178,17 @@ where I: IntoIterator<Item=String>
|
|
|
|
|
"--rebase" => return Ok(Output::Rebase(parse_rebase(args)?)),
|
|
|
|
|
|
|
|
|
|
"--" => reading = false,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[cfg(feature="threads")]
|
|
|
|
|
"--threads" if take_one!() => {
|
|
|
|
|
if one.to_lowercase().trim() == "inf" {
|
|
|
|
|
threads = None;
|
|
|
|
|
} else {
|
|
|
|
|
threads = Some(one.as_str().parse::<std::num::NonZeroUsize>().or_else(|e| Err(Error::BadNumber(e)))?);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
#[cfg(feature="threads")]
|
|
|
|
|
"--sync" => threads = Some(unsafe{std::num::NonZeroUsize::new_unchecked(1)}),
|
|
|
|
|
"--load" => {
|
|
|
|
|
load.push(validate_path(config::DEFAULT_HASHNAME.to_string(), Ensure::File, false)?.to_owned());
|
|
|
|
|
},
|
|
|
|
@ -225,7 +247,12 @@ where I: IntoIterator<Item=String>
|
|
|
|
|
'q' => mode_er = error::Mode::Ignore,
|
|
|
|
|
|
|
|
|
|
'h' => return Ok(Output::Help),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[cfg(feature="threads")]
|
|
|
|
|
'U' => threads = None,
|
|
|
|
|
#[cfg(feature="threads")]
|
|
|
|
|
'S' => threads = Some(unsafe{std::num::NonZeroUsize::new_unchecked(1)}),
|
|
|
|
|
|
|
|
|
|
'r' => mode_rec = config::RecursionMode::All,
|
|
|
|
|
_ => return Err(Error::UnknownArgChar(argchar)),
|
|
|
|
|
}
|
|
|
|
@ -257,6 +284,8 @@ where I: IntoIterator<Item=String>
|
|
|
|
|
},
|
|
|
|
|
save,
|
|
|
|
|
load,
|
|
|
|
|
#[cfg(feature="threads")]
|
|
|
|
|
max_threads: threads,
|
|
|
|
|
}))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -271,6 +300,7 @@ pub enum Error
|
|
|
|
|
ExpectedFile(PathBuf),
|
|
|
|
|
ExpectedDirectory(PathBuf),
|
|
|
|
|
UnknownErrorMode(String),
|
|
|
|
|
BadNumber(std::num::ParseIntError),
|
|
|
|
|
Unknown,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -281,6 +311,7 @@ impl fmt::Display for Error
|
|
|
|
|
{
|
|
|
|
|
write!(f, "failed to parse args: ")?;
|
|
|
|
|
match self {
|
|
|
|
|
Error::BadNumber(num) => write!(f, "{}", num),
|
|
|
|
|
Error::NoInput => write!(f, "need at least one input"),
|
|
|
|
|
Error::Parse(value, typ) => write!(f, "expected a {}, got `{}'", typ, value),
|
|
|
|
|
Error::UnknownArg(arg) => write!(f, "i don't know how to `{}'", arg),
|
|
|
|
|