mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 19:47:45 +00:00
expand: update to clap 4
This commit is contained in:
parent
b7c1216a1a
commit
6cc6f35155
2 changed files with 11 additions and 11 deletions
|
@ -15,7 +15,7 @@ edition = "2021"
|
||||||
path = "src/expand.rs"
|
path = "src/expand.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
clap = { version = "3.2", features = ["wrap_help", "cargo"] }
|
clap = { version = "4.0", features = ["wrap_help", "cargo"] }
|
||||||
unicode-width = "0.1.5"
|
unicode-width = "0.1.5"
|
||||||
uucore = { version=">=0.0.16", package="uucore", path="../../uucore" }
|
uucore = { version=">=0.0.16", package="uucore", path="../../uucore" }
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate uucore;
|
extern crate uucore;
|
||||||
|
|
||||||
use clap::{crate_version, Arg, ArgMatches, Command};
|
use clap::{crate_version, Arg, ArgAction, ArgMatches, Command};
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
|
@ -216,8 +216,8 @@ impl Options {
|
||||||
None => (RemainingMode::None, vec![DEFAULT_TABSTOP]),
|
None => (RemainingMode::None, vec![DEFAULT_TABSTOP]),
|
||||||
};
|
};
|
||||||
|
|
||||||
let iflag = matches.contains_id(options::INITIAL);
|
let iflag = matches.get_flag(options::INITIAL);
|
||||||
let uflag = !matches.contains_id(options::NO_UTF8);
|
let uflag = !matches.get_flag(options::NO_UTF8);
|
||||||
|
|
||||||
// avoid allocations when dumping out long sequences of spaces
|
// avoid allocations when dumping out long sequences of spaces
|
||||||
// by precomputing the longest string of spaces we will ever need
|
// by precomputing the longest string of spaces we will ever need
|
||||||
|
@ -276,7 +276,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
expand(&Options::new(&matches)?).map_err_context(|| "failed to write output".to_string())
|
expand(&Options::new(&matches)?).map_err_context(|| "failed to write output".to_string())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uu_app<'a>() -> Command<'a> {
|
pub fn uu_app() -> Command {
|
||||||
Command::new(uucore::util_name())
|
Command::new(uucore::util_name())
|
||||||
.version(crate_version!())
|
.version(crate_version!())
|
||||||
.about(ABOUT)
|
.about(ABOUT)
|
||||||
|
@ -287,15 +287,15 @@ pub fn uu_app<'a>() -> Command<'a> {
|
||||||
Arg::new(options::INITIAL)
|
Arg::new(options::INITIAL)
|
||||||
.long(options::INITIAL)
|
.long(options::INITIAL)
|
||||||
.short('i')
|
.short('i')
|
||||||
.help("do not convert tabs after non blanks"),
|
.help("do not convert tabs after non blanks")
|
||||||
|
.action(ArgAction::SetTrue),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new(options::TABS)
|
Arg::new(options::TABS)
|
||||||
.long(options::TABS)
|
.long(options::TABS)
|
||||||
.short('t')
|
.short('t')
|
||||||
.value_name("N, LIST")
|
.value_name("N, LIST")
|
||||||
.takes_value(true)
|
.action(ArgAction::Append)
|
||||||
.multiple_occurrences(true)
|
|
||||||
.help(
|
.help(
|
||||||
"have tabs N characters apart, not 8 or use comma separated list \
|
"have tabs N characters apart, not 8 or use comma separated list \
|
||||||
of explicit tab positions",
|
of explicit tab positions",
|
||||||
|
@ -305,13 +305,13 @@ pub fn uu_app<'a>() -> Command<'a> {
|
||||||
Arg::new(options::NO_UTF8)
|
Arg::new(options::NO_UTF8)
|
||||||
.long(options::NO_UTF8)
|
.long(options::NO_UTF8)
|
||||||
.short('U')
|
.short('U')
|
||||||
.help("interpret input file as 8-bit ASCII rather than UTF-8"),
|
.help("interpret input file as 8-bit ASCII rather than UTF-8")
|
||||||
|
.action(ArgAction::SetTrue),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new(options::FILES)
|
Arg::new(options::FILES)
|
||||||
.multiple_occurrences(true)
|
.action(ArgAction::Append)
|
||||||
.hide(true)
|
.hide(true)
|
||||||
.takes_value(true)
|
|
||||||
.value_hint(clap::ValueHint::FilePath),
|
.value_hint(clap::ValueHint::FilePath),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue