mirror of
https://github.com/uutils/coreutils
synced 2024-12-13 14:52:41 +00:00
unexpand: update to clap 4
This commit is contained in:
parent
db464bbeb5
commit
3a234b3b09
2 changed files with 19 additions and 16 deletions
|
@ -15,7 +15,7 @@ edition = "2021"
|
||||||
path = "src/unexpand.rs"
|
path = "src/unexpand.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" }
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate uucore;
|
extern crate uucore;
|
||||||
use clap::{crate_version, Arg, Command};
|
use clap::{crate_version, Arg, ArgAction, Command};
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
|
@ -109,9 +109,9 @@ impl Options {
|
||||||
Some(s) => tabstops_parse(&s.map(|s| s.as_str()).collect::<Vec<_>>().join(","))?,
|
Some(s) => tabstops_parse(&s.map(|s| s.as_str()).collect::<Vec<_>>().join(","))?,
|
||||||
};
|
};
|
||||||
|
|
||||||
let aflag = (matches.contains_id(options::ALL) || matches.contains_id(options::TABS))
|
let aflag = (matches.get_flag(options::ALL) || matches.contains_id(options::TABS))
|
||||||
&& !matches.contains_id(options::FIRST_ONLY);
|
&& !matches.get_flag(options::FIRST_ONLY);
|
||||||
let uflag = !matches.contains_id(options::NO_UTF8);
|
let uflag = !matches.get_flag(options::NO_UTF8);
|
||||||
|
|
||||||
let files = match matches.get_one::<String>(options::FILE) {
|
let files = match matches.get_one::<String>(options::FILE) {
|
||||||
Some(v) => vec![v.to_string()],
|
Some(v) => vec![v.to_string()],
|
||||||
|
@ -172,7 +172,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
unexpand(&Options::new(&matches)?).map_err_context(String::new)
|
unexpand(&Options::new(&matches)?).map_err_context(String::new)
|
||||||
}
|
}
|
||||||
|
|
||||||
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!())
|
||||||
|
@ -182,37 +182,40 @@ pub fn uu_app<'a>() -> Command<'a> {
|
||||||
.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),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new(options::ALL)
|
Arg::new(options::ALL)
|
||||||
.short('a')
|
.short('a')
|
||||||
.long(options::ALL)
|
.long(options::ALL)
|
||||||
.help("convert all blanks, instead of just initial blanks")
|
.help("convert all blanks, instead of just initial blanks")
|
||||||
.takes_value(false),
|
.action(ArgAction::SetTrue),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new(options::FIRST_ONLY)
|
Arg::new(options::FIRST_ONLY)
|
||||||
.long(options::FIRST_ONLY)
|
.long(options::FIRST_ONLY)
|
||||||
.help("convert only leading sequences of blanks (overrides -a)")
|
.help("convert only leading sequences of blanks (overrides -a)")
|
||||||
.takes_value(false),
|
.action(ArgAction::SetTrue),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new(options::TABS)
|
Arg::new(options::TABS)
|
||||||
.short('t')
|
.short('t')
|
||||||
.long(options::TABS)
|
.long(options::TABS)
|
||||||
.help("use comma separated LIST of tab positions or have tabs N characters apart instead of 8 (enables -a)")
|
.help(
|
||||||
.takes_value(true)
|
"use comma separated LIST of tab positions or have tabs N characters \
|
||||||
.multiple_occurrences(true)
|
apart instead of 8 (enables -a)",
|
||||||
.value_name("N, LIST")
|
)
|
||||||
|
.action(ArgAction::Append)
|
||||||
|
.value_name("N, LIST"),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new(options::NO_UTF8)
|
Arg::new(options::NO_UTF8)
|
||||||
.short('U')
|
.short('U')
|
||||||
.long(options::NO_UTF8)
|
.long(options::NO_UTF8)
|
||||||
.takes_value(false)
|
.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),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn open(path: &str) -> BufReader<Box<dyn Read + 'static>> {
|
fn open(path: &str) -> BufReader<Box<dyn Read + 'static>> {
|
||||||
|
|
Loading…
Reference in a new issue