1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 11:37:44 +00:00

Merge pull request #2815 from jfinkels/printf-uresult

printf: return UResult from uumain() function
This commit is contained in:
Terts Diepraam 2021-12-29 15:10:20 +01:00 committed by GitHub
commit 645eea0c09
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -3,6 +3,7 @@
// spell-checker:ignore (ToDO) LONGHELP FORMATSTRING templating parameterizing formatstr
use clap::{crate_version, App, Arg};
use uucore::error::{UResult, UUsageError};
use uucore::InvalidEncodingHandling;
mod cli;
@ -273,18 +274,14 @@ COPYRIGHT :
";
pub fn uumain(args: impl uucore::Args) -> i32 {
#[uucore_procs::gen_uumain]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let args = args
.collect_str(InvalidEncodingHandling::Ignore)
.accept_any();
if args.len() <= 1 {
println!(
"{0}: missing operand\nTry '{1} --help' for more information.",
uucore::util_name(),
uucore::execution_phrase()
);
return 1;
return Err(UUsageError::new(1, "missing operand"));
}
let formatstr = &args[1];
@ -296,7 +293,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
let printf_args = &args[2..];
memo::Memo::run_all(formatstr, printf_args);
}
0
Ok(())
}
pub fn uu_app() -> App<'static, 'static> {