uniq: use UResult in util
@@ -15,6 +15,7 @@ use std::path::Path;
use std::str::FromStr;
use strum_macros::{AsRefStr, EnumString};
use uucore::display::Quotable;
+use uucore::error::{UResult, USimpleError};
static ABOUT: &str = "Report or omit repeated lines.";
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 long_usage = get_long_usage();
@@ -265,7 +267,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
2 => (files[0].clone(), files[1].clone()),
_ => {
// 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),
);
- 0
+ Ok(())
}
pub fn uu_app() -> App<'static, 'static> {
