mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
Use time-style only if time is provided
This commit is contained in:
parent
ffda2a4b40
commit
49c7e65f5d
2 changed files with 17 additions and 2 deletions
|
@ -721,6 +721,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
excludes: build_exclude_patterns(&matches)?,
|
excludes: build_exclude_patterns(&matches)?,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let time_format = if time.is_some() {
|
||||||
|
parse_time_style(matches.get_one::<String>("time-style").map(|s| s.as_str()))?.to_string()
|
||||||
|
} else {
|
||||||
|
"%Y-%m-%d %H:%M".to_string()
|
||||||
|
};
|
||||||
|
|
||||||
let stat_printer = StatPrinter {
|
let stat_printer = StatPrinter {
|
||||||
max_depth,
|
max_depth,
|
||||||
size_format,
|
size_format,
|
||||||
|
@ -737,8 +743,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
.transpose()?,
|
.transpose()?,
|
||||||
apparent_size: matches.get_flag(options::APPARENT_SIZE) || matches.get_flag(options::BYTES),
|
apparent_size: matches.get_flag(options::APPARENT_SIZE) || matches.get_flag(options::BYTES),
|
||||||
time,
|
time,
|
||||||
time_format: parse_time_style(matches.get_one::<String>("time-style").map(|s| s.as_str()))?
|
time_format,
|
||||||
.to_string(),
|
|
||||||
line_ending: LineEnding::from_zero_flag(matches.get_flag(options::NULL)),
|
line_ending: LineEnding::from_zero_flag(matches.get_flag(options::NULL)),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1116,3 +1116,13 @@ fn test_du_files0_from_combined() {
|
||||||
|
|
||||||
assert!(stderr.contains("file operands cannot be combined with --files0-from"));
|
assert!(stderr.contains("file operands cannot be combined with --files0-from"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_invalid_time_style() {
|
||||||
|
let ts = TestScenario::new(util_name!());
|
||||||
|
ts.ucmd()
|
||||||
|
.arg("-s")
|
||||||
|
.arg("--time-style=banana")
|
||||||
|
.succeeds()
|
||||||
|
.stdout_does_not_contain("du: invalid argument 'banana' for 'time style'");
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue