head: use map_err instead of match in uumain

This commit is contained in:
Daniel Hofstetter
2025-08-19 15:33:30 +02:00
parent 6ca078d2e2
commit 60b2df0b6b
+4 -9
View File
@@ -554,15 +554,10 @@ fn uu_head(options: &HeadOptions) -> UResult<()> {
#[uucore::main]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let args_vec: Vec<_> = arg_iterate(args)?.collect();
let matches = uu_app().get_matches_from_localized(args_vec);
let args = match HeadOptions::get_from(&matches) {
Ok(o) => o,
Err(s) => {
return Err(HeadError::MatchOption(s).into());
}
};
uu_head(&args)
let args: Vec<_> = arg_iterate(args)?.collect();
let matches = uu_app().get_matches_from_localized(args);
let options = HeadOptions::get_from(&matches).map_err(HeadError::MatchOption)?;
uu_head(&options)
}
#[cfg(test)]