mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
ls: accept shortcuts for stringly-enum arguments
This commit is contained in:
parent
27a81f3d32
commit
3877d14504
2 changed files with 128 additions and 32 deletions
|
@ -27,6 +27,7 @@ const LONG_ARGS: &[&str] = &[
|
|||
"-l",
|
||||
"--long",
|
||||
"--format=long",
|
||||
"--format=lon",
|
||||
"--for=long",
|
||||
"--format=verbose",
|
||||
"--for=verbose",
|
||||
|
@ -35,6 +36,7 @@ const LONG_ARGS: &[&str] = &[
|
|||
const ACROSS_ARGS: &[&str] = &[
|
||||
"-x",
|
||||
"--format=across",
|
||||
"--format=acr",
|
||||
"--format=horizontal",
|
||||
"--for=across",
|
||||
"--for=horizontal",
|
||||
|
@ -999,6 +1001,8 @@ fn test_ls_zero() {
|
|||
let ignored_opts = [
|
||||
"--quoting-style=c",
|
||||
"--color=always",
|
||||
"--color=alway",
|
||||
"--color=al",
|
||||
"-m",
|
||||
"--hide-control-chars",
|
||||
];
|
||||
|
@ -1601,6 +1605,24 @@ fn test_ls_deref() {
|
|||
.succeeds();
|
||||
assert!(re.is_match(result.stdout_str().trim()));
|
||||
|
||||
let result = scene
|
||||
.ucmd()
|
||||
.arg("-l")
|
||||
.arg("--color=neve") // spell-checker:disable-line
|
||||
.arg("test-long")
|
||||
.arg("test-long.link")
|
||||
.succeeds();
|
||||
assert!(re.is_match(result.stdout_str().trim()));
|
||||
|
||||
let result = scene
|
||||
.ucmd()
|
||||
.arg("-l")
|
||||
.arg("--color=n")
|
||||
.arg("test-long")
|
||||
.arg("test-long.link")
|
||||
.succeeds();
|
||||
assert!(re.is_match(result.stdout_str().trim()));
|
||||
|
||||
let result = scene
|
||||
.ucmd()
|
||||
.arg("-L")
|
||||
|
@ -1676,6 +1698,10 @@ fn test_ls_sort_none() {
|
|||
// Order is not specified so we just check that it doesn't
|
||||
// give any errors.
|
||||
scene.ucmd().arg("--sort=none").succeeds();
|
||||
scene.ucmd().arg("--sort=non").succeeds();
|
||||
scene.ucmd().arg("--sort=no").succeeds();
|
||||
// scene.ucmd().arg("--sort=n").succeeds();
|
||||
// We refuse to accept "--sort=n", since this is too confusable with "--sort=name", which is our own extension.
|
||||
scene.ucmd().arg("-U").succeeds();
|
||||
}
|
||||
|
||||
|
@ -1693,6 +1719,16 @@ fn test_ls_sort_name() {
|
|||
.arg("--sort=name")
|
||||
.succeeds()
|
||||
.stdout_is("test-1\ntest-2\ntest-3\n");
|
||||
scene
|
||||
.ucmd()
|
||||
.arg("--sort=nam")
|
||||
.succeeds()
|
||||
.stdout_is("test-1\ntest-2\ntest-3\n");
|
||||
scene
|
||||
.ucmd()
|
||||
.arg("--sort=na")
|
||||
.succeeds()
|
||||
.stdout_is("test-1\ntest-2\ntest-3\n");
|
||||
|
||||
let scene_dot = TestScenario::new(util_name!());
|
||||
let at = &scene_dot.fixtures;
|
||||
|
@ -1729,6 +1765,16 @@ fn test_ls_sort_width() {
|
|||
.arg("--sort=width")
|
||||
.succeeds()
|
||||
.stdout_is("d\nzz\nabc\nbbb\neee\ncccc\naaaaa\nbcdef\nfffff\n");
|
||||
scene
|
||||
.ucmd()
|
||||
.arg("--sort=widt") // spell-checker:disable-line
|
||||
.succeeds()
|
||||
.stdout_is("d\nzz\nabc\nbbb\neee\ncccc\naaaaa\nbcdef\nfffff\n");
|
||||
scene
|
||||
.ucmd()
|
||||
.arg("--sort=w")
|
||||
.succeeds()
|
||||
.stdout_is("d\nzz\nabc\nbbb\neee\ncccc\naaaaa\nbcdef\nfffff\n");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -1757,6 +1803,12 @@ fn test_ls_order_size() {
|
|||
let result = scene.ucmd().arg("--sort=size").succeeds();
|
||||
result.stdout_only("test-4\ntest-3\ntest-2\ntest-1\n");
|
||||
|
||||
let result = scene.ucmd().arg("--sort=siz").succeeds();
|
||||
result.stdout_only("test-4\ntest-3\ntest-2\ntest-1\n");
|
||||
|
||||
let result = scene.ucmd().arg("--sort=s").succeeds();
|
||||
result.stdout_only("test-4\ntest-3\ntest-2\ntest-1\n");
|
||||
|
||||
let result = scene.ucmd().arg("--sort=size").arg("-r").succeeds();
|
||||
result.stdout_only("test-1\ntest-2\ntest-3\ntest-4\n");
|
||||
}
|
||||
|
@ -1961,7 +2013,14 @@ fn test_ls_order_time() {
|
|||
|
||||
// 3 was accessed last in the read
|
||||
// So the order should be 2 3 4 1
|
||||
for arg in ["-u", "--time=atime", "--time=access", "--time=use"] {
|
||||
for arg in [
|
||||
"-u",
|
||||
"--time=atime",
|
||||
"--time=atim", // spell-checker:disable-line
|
||||
"--time=a",
|
||||
"--time=access",
|
||||
"--time=use",
|
||||
] {
|
||||
let result = scene.ucmd().arg("-t").arg(arg).succeeds();
|
||||
at.open("test-3").metadata().unwrap().accessed().unwrap();
|
||||
at.open("test-4").metadata().unwrap().accessed().unwrap();
|
||||
|
@ -2216,12 +2275,16 @@ fn test_ls_indicator_style() {
|
|||
for opt in [
|
||||
"--indicator-style=classify",
|
||||
"--ind=classify",
|
||||
"--indicator-style=clas", // spell-checker:disable-line
|
||||
"--indicator-style=c",
|
||||
"--indicator-style=file-type",
|
||||
"--ind=file-type",
|
||||
"--indicator-style=slash",
|
||||
"--ind=slash",
|
||||
"--classify",
|
||||
"--classify=always",
|
||||
"--classify=alway", // spell-checker:disable-line
|
||||
"--classify=al",
|
||||
"--classify=yes",
|
||||
"--classify=force",
|
||||
"--class",
|
||||
|
@ -2236,10 +2299,13 @@ fn test_ls_indicator_style() {
|
|||
// Classify, Indicator options should not contain any indicators when value is none.
|
||||
for opt in [
|
||||
"--indicator-style=none",
|
||||
"--indicator-style=n",
|
||||
"--ind=none",
|
||||
"--classify=none",
|
||||
"--classify=never",
|
||||
"--classify=non",
|
||||
"--classify=no",
|
||||
"--classify=n",
|
||||
] {
|
||||
// Verify that there are no indicators for any of the file types.
|
||||
scene
|
||||
|
@ -2553,6 +2619,12 @@ fn test_ls_version_sort() {
|
|||
expected
|
||||
);
|
||||
|
||||
let result = scene.ucmd().arg("-1").arg("--sort=v").succeeds();
|
||||
assert_eq!(
|
||||
result.stdout_str().split('\n').collect::<Vec<_>>(),
|
||||
expected
|
||||
);
|
||||
|
||||
let result = scene.ucmd().arg("-a1v").succeeds();
|
||||
expected.insert(expected.len() - 1, "..");
|
||||
expected.insert(0, ".");
|
||||
|
@ -2589,19 +2661,27 @@ fn test_ls_quoting_style() {
|
|||
|
||||
for (arg, correct) in [
|
||||
("--quoting-style=literal", "one?two"),
|
||||
("--quoting-style=litera", "one?two"), // spell-checker:disable-line
|
||||
("--quoting-style=li", "one?two"),
|
||||
("-N", "one?two"),
|
||||
("--literal", "one?two"),
|
||||
("--l", "one?two"),
|
||||
("--quoting-style=c", "\"one\\ntwo\""),
|
||||
("--quoting-style=c-", "\"one\\ntwo\""),
|
||||
("--quoting-style=c-maybe", "\"one\\ntwo\""),
|
||||
("-Q", "\"one\\ntwo\""),
|
||||
("--quote-name", "\"one\\ntwo\""),
|
||||
("--quoting-style=escape", "one\\ntwo"),
|
||||
("--quoting-style=escap", "one\\ntwo"), // spell-checker:disable-line
|
||||
("-b", "one\\ntwo"),
|
||||
("--escape", "one\\ntwo"),
|
||||
("--quoting-style=shell-escape", "'one'$'\\n''two'"),
|
||||
("--quoting-style=shell-escape-always", "'one'$'\\n''two'"),
|
||||
("--quoting-style=shell-escape-alway", "'one'$'\\n''two'"),
|
||||
("--quoting-style=shell-escape-a", "'one'$'\\n''two'"),
|
||||
("--quoting-style=shell", "one?two"),
|
||||
("--quoting-style=shell-always", "'one?two'"),
|
||||
("--quoting-style=shell-a", "'one?two'"),
|
||||
] {
|
||||
scene
|
||||
.ucmd()
|
||||
|
@ -4244,11 +4324,18 @@ fn test_ls_hyperlink() {
|
|||
.stdout_str()
|
||||
.contains(&format!("{path}{separator}{file}\x07{file}\x1b]8;;\x07")));
|
||||
|
||||
scene
|
||||
.ucmd()
|
||||
.arg("--hyperlink=never")
|
||||
.succeeds()
|
||||
.stdout_is(format!("{file}\n"));
|
||||
for argument in [
|
||||
"--hyperlink=never",
|
||||
"--hyperlink=neve", // spell-checker:disable-line
|
||||
"--hyperlink=ne", // spell-checker:disable-line
|
||||
"--hyperlink=n",
|
||||
] {
|
||||
scene
|
||||
.ucmd()
|
||||
.arg(argument)
|
||||
.succeeds()
|
||||
.stdout_is(format!("{file}\n"));
|
||||
}
|
||||
}
|
||||
|
||||
// spell-checker: disable
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue