mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 03:27:44 +00:00
* stat: should fail without arguments #5928 * style and lint issue stat: should fail without arguments #5928 * style and lint issue stat: should fail without arguments #5928 * style and lint 2 issue stat: should fail without arguments #5928 --------- Co-authored-by: biplab5464 <biplab5464@outlook.com>
This commit is contained in:
parent
eead44172d
commit
fd4e1cfb28
2 changed files with 14 additions and 1 deletions
|
@ -546,10 +546,16 @@ impl Stater {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn new(matches: &ArgMatches) -> UResult<Self> {
|
fn new(matches: &ArgMatches) -> UResult<Self> {
|
||||||
let files = matches
|
let files: Vec<OsString> = matches
|
||||||
.get_many::<OsString>(options::FILES)
|
.get_many::<OsString>(options::FILES)
|
||||||
.map(|v| v.map(OsString::from).collect())
|
.map(|v| v.map(OsString::from).collect())
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
|
if files.is_empty() {
|
||||||
|
return Err(Box::new(USimpleError {
|
||||||
|
code: 1,
|
||||||
|
message: "missing operand\nTry 'stat --help' for more information.".to_string(),
|
||||||
|
}));
|
||||||
|
}
|
||||||
let format_str = if matches.contains_id(options::PRINTF) {
|
let format_str = if matches.contains_id(options::PRINTF) {
|
||||||
matches
|
matches
|
||||||
.get_one::<String>(options::PRINTF)
|
.get_one::<String>(options::PRINTF)
|
||||||
|
|
|
@ -338,3 +338,10 @@ fn test_stdin_redirect() {
|
||||||
.stdout_contains("File: -")
|
.stdout_contains("File: -")
|
||||||
.succeeded();
|
.succeeded();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_without_argument() {
|
||||||
|
new_ucmd!()
|
||||||
|
.fails()
|
||||||
|
.stderr_contains("missing operand\nTry 'stat --help' for more information.");
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue