1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-08-01 13:37:48 +00:00

Merge pull request #2723 from Smicry/master

uniq: use UResult in util
This commit is contained in:
Sylvestre Ledru 2021-10-23 21:35:51 +02:00 committed by GitHub
commit d286c3ba4b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -15,6 +15,7 @@ use std::path::Path;
use std::str::FromStr; use std::str::FromStr;
use strum_macros::{AsRefStr, EnumString}; use strum_macros::{AsRefStr, EnumString};
use uucore::display::Quotable; use uucore::display::Quotable;
use uucore::error::{UResult, USimpleError};
static ABOUT: &str = "Report or omit repeated lines."; static ABOUT: &str = "Report or omit repeated lines.";
pub mod options { pub mod options {
@ -245,7 +246,8 @@ fn get_long_usage() -> String {
) )
} }
pub fn uumain(args: impl uucore::Args) -> i32 { #[uucore_procs::gen_uumain]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let usage = usage(); let usage = usage();
let long_usage = get_long_usage(); let long_usage = get_long_usage();
@ -265,7 +267,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
2 => (files[0].clone(), files[1].clone()), 2 => (files[0].clone(), files[1].clone()),
_ => { _ => {
// Cannot happen as clap will fail earlier // Cannot happen as clap will fail earlier
crash!(1, "Extra operand: {}", files[2]); return Err(USimpleError::new(1, format!("Extra operand: {}", files[2])));
} }
}; };
@ -288,7 +290,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
&mut open_output_file(out_file_name), &mut open_output_file(out_file_name),
); );
0 Ok(())
} }
pub fn uu_app() -> App<'static, 'static> { pub fn uu_app() -> App<'static, 'static> {