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