1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-09-18 04:36:18 +00:00

echo: clap 3

This commit is contained in:
Terts Diepraam 2022-01-11 13:25:47 +01:00
parent 1f2c3064b8
commit 812f2db464
2 changed files with 14 additions and 21 deletions

View file

@ -15,7 +15,7 @@ edition = "2018"
path = "src/echo.rs" path = "src/echo.rs"
[dependencies] [dependencies]
clap = { version = "2.33", features = ["wrap_help"] } clap = { version = "3.0", features = ["wrap_help", "cargo"] }
uucore = { version=">=0.0.10", package="uucore", path="../../uucore" } uucore = { version=">=0.0.10", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" } uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" }

View file

@ -128,44 +128,37 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
execute(no_newline, escaped, values).map_err_context(|| "could not write to stdout".to_string()) execute(no_newline, escaped, values).map_err_context(|| "could not write to stdout".to_string())
} }
pub fn uu_app() -> App<'static, 'static> { pub fn uu_app<'a>() -> App<'a> {
App::new(uucore::util_name()) App::new(uucore::util_name())
.name(NAME) .name(NAME)
// TrailingVarArg specifies the final positional argument is a VarArg // TrailingVarArg specifies the final positional argument is a VarArg
// and it doesn't attempts the parse any further args. // and it doesn't attempts the parse any further args.
// Final argument must have multiple(true) or the usage string equivalent. // Final argument must have multiple(true) or the usage string equivalent.
.setting(clap::AppSettings::TrailingVarArg) .setting(clap::AppSettings::TrailingVarArg)
.setting(clap::AppSettings::AllowLeadingHyphen) .setting(clap::AppSettings::AllowHyphenValues)
.version(crate_version!()) .version(crate_version!())
.about(SUMMARY) .about(SUMMARY)
.after_help(AFTER_HELP) .after_help(AFTER_HELP)
.usage(USAGE) .override_usage(USAGE)
.arg( .arg(
Arg::with_name(options::NO_NEWLINE) Arg::new(options::NO_NEWLINE)
.short("n") .short('n')
.help("do not output the trailing newline") .help("do not output the trailing newline")
.takes_value(false) .takes_value(false),
.display_order(1),
) )
.arg( .arg(
Arg::with_name(options::ENABLE_BACKSLASH_ESCAPE) Arg::new(options::ENABLE_BACKSLASH_ESCAPE)
.short("e") .short('e')
.help("enable interpretation of backslash escapes") .help("enable interpretation of backslash escapes")
.takes_value(false) .takes_value(false),
.display_order(2),
) )
.arg( .arg(
Arg::with_name(options::DISABLE_BACKSLASH_ESCAPE) Arg::new(options::DISABLE_BACKSLASH_ESCAPE)
.short("E") .short('E')
.help("disable interpretation of backslash escapes (default)") .help("disable interpretation of backslash escapes (default)")
.takes_value(false) .takes_value(false),
.display_order(3),
)
.arg(
Arg::with_name(options::STRING)
.multiple(true)
.allow_hyphen_values(true),
) )
.arg(Arg::new(options::STRING).multiple_occurrences(true))
} }
fn execute(no_newline: bool, escaped: bool, free: Vec<String>) -> io::Result<()> { fn execute(no_newline: bool, escaped: bool, free: Vec<String>) -> io::Result<()> {