1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-29 03:57:44 +00:00

Merge pull request #6690 from LoricAndre/main

fix: add arg count for cp
This commit is contained in:
Sylvestre Ledru 2024-09-10 21:57:35 +02:00 committed by GitHub
commit ac6b115bad
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 19 additions and 0 deletions

View file

@ -677,6 +677,8 @@ pub fn uu_app() -> Command {
.arg( .arg(
Arg::new(options::PATHS) Arg::new(options::PATHS)
.action(ArgAction::Append) .action(ArgAction::Append)
.num_args(1..)
.required(true)
.value_hint(clap::ValueHint::AnyPath) .value_hint(clap::ValueHint::AnyPath)
.value_parser(ValueParser::os_string()), .value_parser(ValueParser::os_string()),
) )

View file

@ -5751,3 +5751,20 @@ fn test_cp_with_options_backup_and_rem_when_dest_is_symlink() {
assert!(!at.symlink_exists("inner_dir/sl")); assert!(!at.symlink_exists("inner_dir/sl"));
assert_eq!(at.read("inner_dir/sl"), "xyz"); assert_eq!(at.read("inner_dir/sl"), "xyz");
} }
#[test]
fn test_cp_single_file() {
let (_at, mut ucmd) = at_and_ucmd!();
ucmd.arg(TEST_HELLO_WORLD_SOURCE)
.fails()
.code_is(1)
.stderr_contains("missing destination file");
}
#[test]
fn test_cp_no_file() {
let (_at, mut ucmd) = at_and_ucmd!();
ucmd.fails()
.code_is(1)
.stderr_contains("error: the following required arguments were not provided:");
}