1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-08-01 05:27:45 +00:00

numfmt: return UResult from uumain() function

This commit is contained in:
Jeffrey Finkelstein 2021-12-28 19:46:20 -05:00
parent f7584cb755
commit 595d4dbb95

View file

@ -7,15 +7,13 @@
// spell-checker:ignore N'th M'th
#[macro_use]
extern crate uucore;
use crate::format::format_and_print;
use crate::options::*;
use crate::units::{Result, Unit};
use clap::{crate_version, App, AppSettings, Arg, ArgMatches};
use std::io::{BufRead, Write};
use uucore::display::Quotable;
use uucore::error::{UResult, USimpleError};
use uucore::ranges::Range;
pub mod format;
@ -154,7 +152,8 @@ fn parse_options(args: &ArgMatches) -> Result<NumfmtOptions> {
})
}
pub fn uumain(args: impl uucore::Args) -> i32 {
#[uucore_procs::gen_uumain]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let usage = usage();
let matches = uu_app().usage(&usage[..]).get_matches_from(args);
@ -168,10 +167,11 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
match result {
Err(e) => {
std::io::stdout().flush().expect("error flushing stdout");
show_error!("{}", e);
1
// TODO Change `handle_args()` and `handle_stdin()` so that
// they return `UResult`.
return Err(USimpleError::new(1, e));
}
_ => 0,
_ => Ok(()),
}
}