mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 19:47:45 +00:00
Merge pull request #2815 from jfinkels/printf-uresult
printf: return UResult from uumain() function
This commit is contained in:
commit
645eea0c09
1 changed files with 5 additions and 8 deletions
|
@ -3,6 +3,7 @@
|
||||||
// spell-checker:ignore (ToDO) LONGHELP FORMATSTRING templating parameterizing formatstr
|
// spell-checker:ignore (ToDO) LONGHELP FORMATSTRING templating parameterizing formatstr
|
||||||
|
|
||||||
use clap::{crate_version, App, Arg};
|
use clap::{crate_version, App, Arg};
|
||||||
|
use uucore::error::{UResult, UUsageError};
|
||||||
use uucore::InvalidEncodingHandling;
|
use uucore::InvalidEncodingHandling;
|
||||||
|
|
||||||
mod cli;
|
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
|
let args = args
|
||||||
.collect_str(InvalidEncodingHandling::Ignore)
|
.collect_str(InvalidEncodingHandling::Ignore)
|
||||||
.accept_any();
|
.accept_any();
|
||||||
|
|
||||||
if args.len() <= 1 {
|
if args.len() <= 1 {
|
||||||
println!(
|
return Err(UUsageError::new(1, "missing operand"));
|
||||||
"{0}: missing operand\nTry '{1} --help' for more information.",
|
|
||||||
uucore::util_name(),
|
|
||||||
uucore::execution_phrase()
|
|
||||||
);
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
let formatstr = &args[1];
|
let formatstr = &args[1];
|
||||||
|
|
||||||
|
@ -296,7 +293,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
let printf_args = &args[2..];
|
let printf_args = &args[2..];
|
||||||
memo::Memo::run_all(formatstr, printf_args);
|
memo::Memo::run_all(formatstr, printf_args);
|
||||||
}
|
}
|
||||||
0
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uu_app() -> App<'static, 'static> {
|
pub fn uu_app() -> App<'static, 'static> {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue