mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
tr: prevent passing options in the wrong place
Note: This requires using the DEPRECATED item Command::trailing_var_arg in clap. This is going to be another [problem with clap](https://github.com/tertsdiepraam/uutils-args/blob/main/docs/design/problems_with_clap.md).
This commit is contained in:
parent
d9b6675bbf
commit
cad94a69be
2 changed files with 25 additions and 0 deletions
|
@ -164,6 +164,7 @@ pub fn uu_app() -> Command {
|
||||||
.about(ABOUT)
|
.about(ABOUT)
|
||||||
.override_usage(format_usage(USAGE))
|
.override_usage(format_usage(USAGE))
|
||||||
.infer_long_args(true)
|
.infer_long_args(true)
|
||||||
|
.trailing_var_arg(true)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new(options::COMPLEMENT)
|
Arg::new(options::COMPLEMENT)
|
||||||
.visible_short_alias('C')
|
.visible_short_alias('C')
|
||||||
|
|
|
@ -78,6 +78,14 @@ fn test_complement1() {
|
||||||
.stdout_is("aX");
|
.stdout_is("aX");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_complement_afterwards_is_not_flag() {
|
||||||
|
new_ucmd!()
|
||||||
|
.args(&["a", "X", "-c"])
|
||||||
|
.fails()
|
||||||
|
.stderr_contains("extra operand '-c'");
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_complement2() {
|
fn test_complement2() {
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
|
@ -127,6 +135,22 @@ fn test_complement_multi_early() {
|
||||||
.stdout_is("aX");
|
.stdout_is("aX");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_complement_multi_middle() {
|
||||||
|
new_ucmd!()
|
||||||
|
.args(&["-c", "a", "-c", "X"])
|
||||||
|
.fails()
|
||||||
|
.stderr_contains("tr: extra operand 'X'");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_complement_multi_late() {
|
||||||
|
new_ucmd!()
|
||||||
|
.args(&["-c", "a", "X", "-c"])
|
||||||
|
.fails()
|
||||||
|
.stderr_contains("tr: extra operand '-c'");
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_squeeze() {
|
fn test_squeeze() {
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue