From 595d4dbb953bd635fc4526acdba7f3d82b155d16 Mon Sep 17 00:00:00 2001 From: Jeffrey Finkelstein Date: Tue, 28 Dec 2021 19:46:20 -0500 Subject: [PATCH] numfmt: return UResult from uumain() function --- src/uu/numfmt/src/numfmt.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/uu/numfmt/src/numfmt.rs b/src/uu/numfmt/src/numfmt.rs index da2fa8130..b49b85c66 100644 --- a/src/uu/numfmt/src/numfmt.rs +++ b/src/uu/numfmt/src/numfmt.rs @@ -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 { }) } -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(()), } }