1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-29 12:07:46 +00:00

comm: update to clap 4

This commit is contained in:
Terts Diepraam 2022-09-29 15:45:32 +02:00
parent 73a7b7f982
commit 34ad013155
2 changed files with 14 additions and 11 deletions

View file

@ -15,7 +15,7 @@ edition = "2021"
path = "src/comm.rs" path = "src/comm.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]]

View file

@ -15,7 +15,7 @@ use uucore::error::FromIo;
use uucore::error::UResult; use uucore::error::UResult;
use uucore::format_usage; use uucore::format_usage;
use clap::{crate_version, Arg, ArgMatches, Command}; use clap::{crate_version, Arg, ArgAction, ArgMatches, Command};
static ABOUT: &str = "compare two sorted files line by line"; static ABOUT: &str = "compare two sorted files line by line";
static LONG_HELP: &str = ""; static LONG_HELP: &str = "";
@ -38,10 +38,10 @@ fn mkdelim(col: usize, opts: &ArgMatches) -> String {
delim => delim, delim => delim,
}; };
if col > 1 && !opts.contains_id(options::COLUMN_1) { if col > 1 && !opts.get_flag(options::COLUMN_1) {
s.push_str(delim.as_ref()); s.push_str(delim.as_ref());
} }
if col > 2 && !opts.contains_id(options::COLUMN_2) { if col > 2 && !opts.get_flag(options::COLUMN_2) {
s.push_str(delim.as_ref()); s.push_str(delim.as_ref());
} }
@ -91,7 +91,7 @@ fn comm(a: &mut LineReader, b: &mut LineReader, opts: &ArgMatches) {
match ord { match ord {
Ordering::Less => { Ordering::Less => {
if !opts.contains_id(options::COLUMN_1) { if !opts.get_flag(options::COLUMN_1) {
ensure_nl(ra); ensure_nl(ra);
print!("{}{}", delim[1], ra); print!("{}{}", delim[1], ra);
} }
@ -99,7 +99,7 @@ fn comm(a: &mut LineReader, b: &mut LineReader, opts: &ArgMatches) {
na = a.read_line(ra); na = a.read_line(ra);
} }
Ordering::Greater => { Ordering::Greater => {
if !opts.contains_id(options::COLUMN_2) { if !opts.get_flag(options::COLUMN_2) {
ensure_nl(rb); ensure_nl(rb);
print!("{}{}", delim[2], rb); print!("{}{}", delim[2], rb);
} }
@ -107,7 +107,7 @@ fn comm(a: &mut LineReader, b: &mut LineReader, opts: &ArgMatches) {
nb = b.read_line(rb); nb = b.read_line(rb);
} }
Ordering::Equal => { Ordering::Equal => {
if !opts.contains_id(options::COLUMN_3) { if !opts.get_flag(options::COLUMN_3) {
ensure_nl(ra); ensure_nl(ra);
print!("{}{}", delim[3], ra); print!("{}{}", delim[3], ra);
} }
@ -144,7 +144,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
Ok(()) Ok(())
} }
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)
@ -154,17 +154,20 @@ pub fn uu_app<'a>() -> Command<'a> {
.arg( .arg(
Arg::new(options::COLUMN_1) Arg::new(options::COLUMN_1)
.short('1') .short('1')
.help("suppress column 1 (lines unique to FILE1)"), .help("suppress column 1 (lines unique to FILE1)")
.action(ArgAction::SetTrue),
) )
.arg( .arg(
Arg::new(options::COLUMN_2) Arg::new(options::COLUMN_2)
.short('2') .short('2')
.help("suppress column 2 (lines unique to FILE2)"), .help("suppress column 2 (lines unique to FILE2)")
.action(ArgAction::SetTrue),
) )
.arg( .arg(
Arg::new(options::COLUMN_3) Arg::new(options::COLUMN_3)
.short('3') .short('3')
.help("suppress column 3 (lines that appear in both files)"), .help("suppress column 3 (lines that appear in both files)")
.action(ArgAction::SetTrue),
) )
.arg( .arg(
Arg::new(options::DELIMITER) Arg::new(options::DELIMITER)