mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-09-16 19:56:17 +00:00
fold: update to clap 4
This commit is contained in:
parent
c485c47503
commit
6ee19a42a4
2 changed files with 9 additions and 10 deletions
|
@ -15,7 +15,7 @@ edition = "2021"
|
||||||
path = "src/fold.rs"
|
path = "src/fold.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
clap = { version = "3.2", features = ["wrap_help", "cargo"] }
|
clap = { version = "4.0", features = ["wrap_help", "cargo"] }
|
||||||
uucore = { version=">=0.0.16", package="uucore", path="../../uucore" }
|
uucore = { version=">=0.0.16", package="uucore", path="../../uucore" }
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
// spell-checker:ignore (ToDOs) ncount routput
|
// spell-checker:ignore (ToDOs) ncount routput
|
||||||
|
|
||||||
use clap::{crate_version, Arg, Command};
|
use clap::{crate_version, Arg, ArgAction, Command};
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::{stdin, BufRead, BufReader, Read};
|
use std::io::{stdin, BufRead, BufReader, Read};
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
@ -36,8 +36,8 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
let (args, obs_width) = handle_obsolete(&args[..]);
|
let (args, obs_width) = handle_obsolete(&args[..]);
|
||||||
let matches = uu_app().try_get_matches_from(args)?;
|
let matches = uu_app().try_get_matches_from(args)?;
|
||||||
|
|
||||||
let bytes = matches.contains_id(options::BYTES);
|
let bytes = matches.get_flag(options::BYTES);
|
||||||
let spaces = matches.contains_id(options::SPACES);
|
let spaces = matches.get_flag(options::SPACES);
|
||||||
let poss_width = match matches.get_one::<String>(options::WIDTH) {
|
let poss_width = match matches.get_one::<String>(options::WIDTH) {
|
||||||
Some(v) => Some(v.to_owned()),
|
Some(v) => Some(v.to_owned()),
|
||||||
None => obs_width,
|
None => obs_width,
|
||||||
|
@ -61,7 +61,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
fold(&files, bytes, spaces, width)
|
fold(&files, bytes, spaces, width)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uu_app<'a>() -> Command<'a> {
|
pub fn uu_app() -> Command {
|
||||||
Command::new(uucore::util_name())
|
Command::new(uucore::util_name())
|
||||||
.name(NAME)
|
.name(NAME)
|
||||||
.version(crate_version!())
|
.version(crate_version!())
|
||||||
|
@ -76,14 +76,14 @@ pub fn uu_app<'a>() -> Command<'a> {
|
||||||
"count using bytes rather than columns (meaning control characters \
|
"count using bytes rather than columns (meaning control characters \
|
||||||
such as newline are not treated specially)",
|
such as newline are not treated specially)",
|
||||||
)
|
)
|
||||||
.takes_value(false),
|
.action(ArgAction::SetTrue),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new(options::SPACES)
|
Arg::new(options::SPACES)
|
||||||
.long(options::SPACES)
|
.long(options::SPACES)
|
||||||
.short('s')
|
.short('s')
|
||||||
.help("break lines at word boundaries rather than a hard cut-off")
|
.help("break lines at word boundaries rather than a hard cut-off")
|
||||||
.takes_value(false),
|
.action(ArgAction::SetTrue),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new(options::WIDTH)
|
Arg::new(options::WIDTH)
|
||||||
|
@ -91,13 +91,12 @@ pub fn uu_app<'a>() -> Command<'a> {
|
||||||
.short('w')
|
.short('w')
|
||||||
.help("set WIDTH as the maximum line width rather than 80")
|
.help("set WIDTH as the maximum line width rather than 80")
|
||||||
.value_name("WIDTH")
|
.value_name("WIDTH")
|
||||||
.allow_hyphen_values(true)
|
.allow_hyphen_values(true),
|
||||||
.takes_value(true),
|
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new(options::FILE)
|
Arg::new(options::FILE)
|
||||||
.hide(true)
|
.hide(true)
|
||||||
.multiple_occurrences(true)
|
.action(ArgAction::Append)
|
||||||
.value_hint(clap::ValueHint::FilePath),
|
.value_hint(clap::ValueHint::FilePath),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue