mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 03:27:44 +00:00
tr: more explicit flag names (#1966)
This commit is contained in:
parent
32ddef9b9e
commit
d88de3c6a6
1 changed files with 13 additions and 13 deletions
|
@ -225,10 +225,10 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
.arg(Arg::with_name(options::SETS).multiple(true))
|
.arg(Arg::with_name(options::SETS).multiple(true))
|
||||||
.get_matches_from(args);
|
.get_matches_from(args);
|
||||||
|
|
||||||
let dflag = matches.is_present(options::DELETE);
|
let delete_flag = matches.is_present(options::DELETE);
|
||||||
let cflag = matches.is_present(options::COMPLEMENT);
|
let complement_flag = matches.is_present(options::COMPLEMENT);
|
||||||
let sflag = matches.is_present(options::SQUEEZE);
|
let squeeze_flag = matches.is_present(options::SQUEEZE);
|
||||||
let tflag = matches.is_present(options::TRUNCATE);
|
let truncate_flag = matches.is_present(options::TRUNCATE);
|
||||||
|
|
||||||
let sets: Vec<String> = match matches.values_of(options::SETS) {
|
let sets: Vec<String> = match matches.values_of(options::SETS) {
|
||||||
Some(v) => v.map(|v| v.to_string()).collect(),
|
Some(v) => v.map(|v| v.to_string()).collect(),
|
||||||
|
@ -243,7 +243,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if !(dflag || sflag) && sets.len() < 2 {
|
if !(delete_flag || squeeze_flag) && sets.len() < 2 {
|
||||||
show_error!(
|
show_error!(
|
||||||
"missing operand after ‘{}’\nTry `{} --help` for more information.",
|
"missing operand after ‘{}’\nTry `{} --help` for more information.",
|
||||||
sets[0],
|
sets[0],
|
||||||
|
@ -252,7 +252,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if cflag && !dflag && !sflag {
|
if complement_flag && !delete_flag && !squeeze_flag {
|
||||||
show_error!("-c is only supported with -d or -s");
|
show_error!("-c is only supported with -d or -s");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -264,21 +264,21 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
let mut buffered_stdout = BufWriter::new(locked_stdout);
|
let mut buffered_stdout = BufWriter::new(locked_stdout);
|
||||||
|
|
||||||
let set1 = ExpandSet::new(sets[0].as_ref());
|
let set1 = ExpandSet::new(sets[0].as_ref());
|
||||||
if dflag {
|
if delete_flag {
|
||||||
if sflag {
|
if squeeze_flag {
|
||||||
let set2 = ExpandSet::new(sets[1].as_ref());
|
let set2 = ExpandSet::new(sets[1].as_ref());
|
||||||
let op = DeleteAndSqueezeOperation::new(set1, set2, cflag);
|
let op = DeleteAndSqueezeOperation::new(set1, set2, complement_flag);
|
||||||
translate_input(&mut locked_stdin, &mut buffered_stdout, op);
|
translate_input(&mut locked_stdin, &mut buffered_stdout, op);
|
||||||
} else {
|
} else {
|
||||||
let op = DeleteOperation::new(set1, cflag);
|
let op = DeleteOperation::new(set1, complement_flag);
|
||||||
translate_input(&mut locked_stdin, &mut buffered_stdout, op);
|
translate_input(&mut locked_stdin, &mut buffered_stdout, op);
|
||||||
}
|
}
|
||||||
} else if sflag {
|
} else if squeeze_flag {
|
||||||
let op = SqueezeOperation::new(set1, cflag);
|
let op = SqueezeOperation::new(set1, complement_flag);
|
||||||
translate_input(&mut locked_stdin, &mut buffered_stdout, op);
|
translate_input(&mut locked_stdin, &mut buffered_stdout, op);
|
||||||
} else {
|
} else {
|
||||||
let mut set2 = ExpandSet::new(sets[1].as_ref());
|
let mut set2 = ExpandSet::new(sets[1].as_ref());
|
||||||
let op = TranslateOperation::new(set1, &mut set2, tflag);
|
let op = TranslateOperation::new(set1, &mut set2, truncate_flag);
|
||||||
translate_input(&mut locked_stdin, &mut buffered_stdout, op)
|
translate_input(&mut locked_stdin, &mut buffered_stdout, op)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue