truncate: use `map_err` instead of `unwrap_or_else`
@@ -116,15 +116,13 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
.override_usage(&usage[..])
.after_help(&long_usage[..])
.try_get_matches_from(args)
- .unwrap_or_else(|e| {
+ .map_err(|e| {
e.print().expect("Error writing clap::Error");
match e.kind {
- clap::ErrorKind::DisplayHelp | clap::ErrorKind::DisplayVersion => {
- std::process::exit(0)
+ clap::ErrorKind::DisplayHelp | clap::ErrorKind::DisplayVersion => 0,
+ _ => 1,
}
- _ => std::process::exit(1),
- }
- });
+ })?;
let files: Vec<String> = matches
.values_of(options::ARG_FILES)
