mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 03:27:44 +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.
|
// file that was distributed with this source code.
|
||||||
|
|
||||||
use chrono::{DateTime, Local};
|
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 glob::Pattern;
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
use std::env;
|
use std::env;
|
||||||
|
@ -30,6 +30,7 @@ use uucore::error::{set_exit_code, FromIo, UError, UResult, USimpleError};
|
||||||
use uucore::line_ending::LineEnding;
|
use uucore::line_ending::LineEnding;
|
||||||
use uucore::parse_glob;
|
use uucore::parse_glob;
|
||||||
use uucore::parse_size::{parse_size_u64, ParseSizeError};
|
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};
|
use uucore::{format_usage, help_about, help_section, help_usage, show, show_error, show_warning};
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
use windows_sys::Win32::Foundation::HANDLE;
|
use windows_sys::Win32::Foundation::HANDLE;
|
||||||
|
@ -1040,7 +1041,11 @@ pub fn uu_app() -> Command {
|
||||||
.value_name("WORD")
|
.value_name("WORD")
|
||||||
.require_equals(true)
|
.require_equals(true)
|
||||||
.num_args(0..)
|
.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(
|
.help(
|
||||||
"show time of the last modification of any file in the \
|
"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 \
|
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
|
// For the full copyright and license information, please view the LICENSE
|
||||||
// file that was distributed with this source code.
|
// 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))]
|
#[cfg(not(windows))]
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
|
|
||||||
|
@ -576,13 +576,15 @@ fn test_du_time() {
|
||||||
.succeeds();
|
.succeeds();
|
||||||
result.stdout_only("0\t2016-06-16 00:00\tdate_test\n");
|
result.stdout_only("0\t2016-06-16 00:00\tdate_test\n");
|
||||||
|
|
||||||
let result = ts
|
for argument in ["--time=atime", "--time=atim", "--time=a"] {
|
||||||
.ucmd()
|
let result = ts
|
||||||
.env("TZ", "UTC")
|
.ucmd()
|
||||||
.arg("--time=atime")
|
.env("TZ", "UTC")
|
||||||
.arg("date_test")
|
.arg(argument)
|
||||||
.succeeds();
|
.arg("date_test")
|
||||||
result.stdout_only("0\t2015-05-15 00:00\tdate_test\n");
|
.succeeds();
|
||||||
|
result.stdout_only("0\t2015-05-15 00:00\tdate_test\n");
|
||||||
|
}
|
||||||
|
|
||||||
let result = ts
|
let result = ts
|
||||||
.ucmd()
|
.ucmd()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue