mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-09-16 19:56:17 +00:00
csplit: update to clap 4
This commit is contained in:
parent
042bb3c4e3
commit
e8d24f97ae
2 changed files with 16 additions and 12 deletions
|
@ -15,7 +15,7 @@ edition = "2021"
|
||||||
path = "src/csplit.rs"
|
path = "src/csplit.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
clap = { version = "3.2", features = ["wrap_help", "cargo"] }
|
clap = { version = "4.0", features = ["wrap_help", "cargo"] }
|
||||||
thiserror = "1.0"
|
thiserror = "1.0"
|
||||||
regex = "1.6.0"
|
regex = "1.6.0"
|
||||||
uucore = { version=">=0.0.16", package="uucore", path="../../uucore", features=["entries", "fs"] }
|
uucore = { version=">=0.0.16", package="uucore", path="../../uucore", features=["entries", "fs"] }
|
||||||
|
|
|
@ -12,7 +12,7 @@ use std::{
|
||||||
io::{BufRead, BufWriter, Write},
|
io::{BufRead, BufWriter, Write},
|
||||||
};
|
};
|
||||||
|
|
||||||
use clap::{crate_version, Arg, ArgMatches, Command};
|
use clap::{crate_version, Arg, ArgAction, ArgMatches, Command};
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
use uucore::display::Quotable;
|
use uucore::display::Quotable;
|
||||||
use uucore::error::{FromIo, UResult};
|
use uucore::error::{FromIo, UResult};
|
||||||
|
@ -52,10 +52,10 @@ pub struct CsplitOptions {
|
||||||
|
|
||||||
impl CsplitOptions {
|
impl CsplitOptions {
|
||||||
fn new(matches: &ArgMatches) -> Self {
|
fn new(matches: &ArgMatches) -> Self {
|
||||||
let keep_files = matches.contains_id(options::KEEP_FILES);
|
let keep_files = matches.get_flag(options::KEEP_FILES);
|
||||||
let quiet = matches.contains_id(options::QUIET);
|
let quiet = matches.get_flag(options::QUIET);
|
||||||
let elide_empty_files = matches.contains_id(options::ELIDE_EMPTY_FILES);
|
let elide_empty_files = matches.get_flag(options::ELIDE_EMPTY_FILES);
|
||||||
let suppress_matched = matches.contains_id(options::SUPPRESS_MATCHED);
|
let suppress_matched = matches.get_flag(options::SUPPRESS_MATCHED);
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
split_name: crash_if_err!(
|
split_name: crash_if_err!(
|
||||||
|
@ -750,7 +750,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
||||||
|
@ -774,12 +774,14 @@ pub fn uu_app<'a>() -> Command<'a> {
|
||||||
Arg::new(options::KEEP_FILES)
|
Arg::new(options::KEEP_FILES)
|
||||||
.short('k')
|
.short('k')
|
||||||
.long(options::KEEP_FILES)
|
.long(options::KEEP_FILES)
|
||||||
.help("do not remove output files on errors"),
|
.help("do not remove output files on errors")
|
||||||
|
.action(ArgAction::SetTrue),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new(options::SUPPRESS_MATCHED)
|
Arg::new(options::SUPPRESS_MATCHED)
|
||||||
.long(options::SUPPRESS_MATCHED)
|
.long(options::SUPPRESS_MATCHED)
|
||||||
.help("suppress the lines matching PATTERN"),
|
.help("suppress the lines matching PATTERN")
|
||||||
|
.action(ArgAction::SetTrue),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new(options::DIGITS)
|
Arg::new(options::DIGITS)
|
||||||
|
@ -793,13 +795,15 @@ pub fn uu_app<'a>() -> Command<'a> {
|
||||||
.short('s')
|
.short('s')
|
||||||
.long(options::QUIET)
|
.long(options::QUIET)
|
||||||
.visible_alias("silent")
|
.visible_alias("silent")
|
||||||
.help("do not print counts of output file sizes"),
|
.help("do not print counts of output file sizes")
|
||||||
|
.action(ArgAction::SetTrue),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new(options::ELIDE_EMPTY_FILES)
|
Arg::new(options::ELIDE_EMPTY_FILES)
|
||||||
.short('z')
|
.short('z')
|
||||||
.long(options::ELIDE_EMPTY_FILES)
|
.long(options::ELIDE_EMPTY_FILES)
|
||||||
.help("remove empty output files"),
|
.help("remove empty output files")
|
||||||
|
.action(ArgAction::SetTrue),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new(options::FILE)
|
Arg::new(options::FILE)
|
||||||
|
@ -810,7 +814,7 @@ pub fn uu_app<'a>() -> Command<'a> {
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new(options::PATTERN)
|
Arg::new(options::PATTERN)
|
||||||
.hide(true)
|
.hide(true)
|
||||||
.multiple_occurrences(true)
|
.action(clap::ArgAction::Append)
|
||||||
.required(true),
|
.required(true),
|
||||||
)
|
)
|
||||||
.after_help(LONG_HELP)
|
.after_help(LONG_HELP)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue