Improve API argument parsing and help information
This commit is contained in:
parent
af98e133dc
commit
ea41cbdbc6
1 changed files with 12 additions and 1 deletions
|
@ -22,6 +22,10 @@ impl CmdArg for ArgApi {
|
|||
.hide_env_values(true)
|
||||
.global(true)
|
||||
.help("Server API version to use, '-' to lookup")
|
||||
.long_help("Server API version to use, one of:\n\
|
||||
2, 3: Firefox Send API versions\n\
|
||||
auto, -: probe server to determine\
|
||||
")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -36,7 +40,7 @@ impl<'a> CmdArgOption<'a> for ArgApi {
|
|||
};
|
||||
|
||||
// Parse the lookup version string
|
||||
if version.trim() == "-" {
|
||||
if is_auto(version) {
|
||||
return DesiredVersion::Lookup;
|
||||
}
|
||||
|
||||
|
@ -50,3 +54,10 @@ impl<'a> CmdArgOption<'a> for ArgApi {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Check whether the given API version argument means we've to probe the server for the proper
|
||||
/// version.
|
||||
fn is_auto(arg: &str) -> bool {
|
||||
let arg = arg.trim().to_lowercase();
|
||||
arg == "a" || arg == "auto" || arg == "-"
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue