1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-31 13:07:46 +00:00

Added UResult for dirname

This commit is contained in:
353fc443 2021-07-02 12:14:24 +00:00
parent f66f10c4ed
commit 23f5f55560
No known key found for this signature in database
GPG key ID: D58B14ED3D42A937

View file

@ -10,6 +10,7 @@ extern crate uucore;
use clap::{crate_version, App, Arg}; use clap::{crate_version, App, Arg};
use std::path::Path; use std::path::Path;
use uucore::error::{UResult, USimpleError};
use uucore::InvalidEncodingHandling; use uucore::InvalidEncodingHandling;
static ABOUT: &str = "strip last component from file name"; static ABOUT: &str = "strip last component from file name";
@ -30,7 +31,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 args = args let args = args
.collect_str(InvalidEncodingHandling::ConvertLossy) .collect_str(InvalidEncodingHandling::ConvertLossy)
.accept_any(); .accept_any();
@ -77,11 +79,10 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
print!("{}", separator); print!("{}", separator);
} }
} else { } else {
show_usage_error!("missing operand"); return Err(USimpleError::new(1, format!("missing operand")));
return 1;
} }
0 Ok(())
} }
pub fn uu_app() -> App<'static, 'static> { pub fn uu_app() -> App<'static, 'static> {