mirror of
https://github.com/uutils/coreutils
synced 2024-12-12 22:32:53 +00:00
du: accept shortcuts for stringly-enum arguments
This commit is contained in:
parent
d4546ced26
commit
27a81f3d32
2 changed files with 17 additions and 10 deletions
|
@ -4,7 +4,7 @@
|
|||
// file that was distributed with this source code.
|
||||
|
||||
use chrono::{DateTime, Local};
|
||||
use clap::{crate_version, Arg, ArgAction, ArgMatches, Command};
|
||||
use clap::{builder::PossibleValue, crate_version, Arg, ArgAction, ArgMatches, Command};
|
||||
use glob::Pattern;
|
||||
use std::collections::HashSet;
|
||||
use std::env;
|
||||
|
@ -30,6 +30,7 @@ use uucore::error::{set_exit_code, FromIo, UError, UResult, USimpleError};
|
|||
use uucore::line_ending::LineEnding;
|
||||
use uucore::parse_glob;
|
||||
use uucore::parse_size::{parse_size_u64, ParseSizeError};
|
||||
use uucore::shortcut_value_parser::ShortcutValueParser;
|
||||
use uucore::{format_usage, help_about, help_section, help_usage, show, show_error, show_warning};
|
||||
#[cfg(windows)]
|
||||
use windows_sys::Win32::Foundation::HANDLE;
|
||||
|
@ -1040,7 +1041,11 @@ pub fn uu_app() -> Command {
|
|||
.value_name("WORD")
|
||||
.require_equals(true)
|
||||
.num_args(0..)
|
||||
.value_parser(["atime", "access", "use", "ctime", "status", "birth", "creation"])
|
||||
.value_parser(ShortcutValueParser::new([
|
||||
PossibleValue::new("atime").alias("access").alias("use"),
|
||||
PossibleValue::new("ctime").alias("status"),
|
||||
PossibleValue::new("creation").alias("birth"),
|
||||
]))
|
||||
.help(
|
||||
"show time of the last modification of any file in the \
|
||||
directory, or any of its subdirectories. If WORD is given, show time as WORD instead \
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
// For the full copyright and license information, please view the LICENSE
|
||||
// file that was distributed with this source code.
|
||||
|
||||
// spell-checker:ignore (paths) sublink subwords azerty azeaze xcwww azeaz amaz azea qzerty tazerty tsublink testfile1 testfile2 filelist testdir testfile
|
||||
// spell-checker:ignore (paths) atim sublink subwords azerty azeaze xcwww azeaz amaz azea qzerty tazerty tsublink testfile1 testfile2 filelist testdir testfile
|
||||
#[cfg(not(windows))]
|
||||
use regex::Regex;
|
||||
|
||||
|
@ -576,13 +576,15 @@ fn test_du_time() {
|
|||
.succeeds();
|
||||
result.stdout_only("0\t2016-06-16 00:00\tdate_test\n");
|
||||
|
||||
let result = ts
|
||||
.ucmd()
|
||||
.env("TZ", "UTC")
|
||||
.arg("--time=atime")
|
||||
.arg("date_test")
|
||||
.succeeds();
|
||||
result.stdout_only("0\t2015-05-15 00:00\tdate_test\n");
|
||||
for argument in ["--time=atime", "--time=atim", "--time=a"] {
|
||||
let result = ts
|
||||
.ucmd()
|
||||
.env("TZ", "UTC")
|
||||
.arg(argument)
|
||||
.arg("date_test")
|
||||
.succeeds();
|
||||
result.stdout_only("0\t2015-05-15 00:00\tdate_test\n");
|
||||
}
|
||||
|
||||
let result = ts
|
||||
.ucmd()
|
||||
|
|
Loading…
Reference in a new issue