diff --git a/src/uu/mknod/Cargo.toml b/src/uu/mknod/Cargo.toml index 95d890d6e..deffa1af6 100644 --- a/src/uu/mknod/Cargo.toml +++ b/src/uu/mknod/Cargo.toml @@ -16,7 +16,7 @@ name = "uu_mknod" path = "src/mknod.rs" [dependencies] -clap = { version = "2.33", features = ["wrap_help"] } +clap = { version = "3.0", features = ["wrap_help", "cargo"] } libc = "^0.2.42" uucore = { version=">=0.0.10", package="uucore", path="../../uucore", features=["mode"] } uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/mknod/src/mknod.rs b/src/uu/mknod/src/mknod.rs index b93716a63..bee4bade2 100644 --- a/src/uu/mknod/src/mknod.rs +++ b/src/uu/mknod/src/mknod.rs @@ -143,28 +143,28 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { } } -pub fn uu_app() -> App<'static, 'static> { +pub fn uu_app<'a>() -> App<'a> { App::new(uucore::util_name()) .version(crate_version!()) - .usage(USAGE) + .override_usage(USAGE) .after_help(LONG_HELP) .about(ABOUT) .arg( - Arg::with_name("mode") - .short("m") + Arg::new("mode") + .short('m') .long("mode") .value_name("MODE") .help("set file permission bits to MODE, not a=rw - umask"), ) .arg( - Arg::with_name("name") + Arg::new("name") .value_name("NAME") .help("name of the new file") .required(true) .index(1), ) .arg( - Arg::with_name("type") + Arg::new("type") .value_name("TYPE") .help("type of the new file (b, c, u or p)") .required(true) @@ -172,14 +172,14 @@ pub fn uu_app() -> App<'static, 'static> { .index(2), ) .arg( - Arg::with_name("major") + Arg::new("major") .value_name("MAJOR") .help("major file type") .validator(valid_u64) .index(3), ) .arg( - Arg::with_name("minor") + Arg::new("minor") .value_name("MINOR") .help("minor file type") .validator(valid_u64) @@ -202,7 +202,7 @@ fn get_mode(matches: &ArgMatches) -> Result { } } -fn valid_type(tpe: String) -> Result<(), String> { +fn valid_type(tpe: &str) -> Result<(), String> { // Only check the first character, to allow mnemonic usage like // 'mknod /dev/rst0 character 18 0'. tpe.chars() @@ -217,6 +217,6 @@ fn valid_type(tpe: String) -> Result<(), String> { }) } -fn valid_u64(num: String) -> Result<(), String> { - num.parse::().map(|_| ()).map_err(|_| num) +fn valid_u64(num: &str) -> Result<(), String> { + num.parse::().map(|_| ()).map_err(|_| num.into()) } diff --git a/tests/by-util/test_mknod.rs b/tests/by-util/test_mknod.rs index 1d39372ac..f42ab0b90 100644 --- a/tests/by-util/test_mknod.rs +++ b/tests/by-util/test_mknod.rs @@ -86,7 +86,6 @@ fn test_mknod_character_device_requires_major_and_minor() { .arg("1") .arg("c") .fails() - .status_code(1) .stderr_contains(&"Invalid value for ''"); new_ucmd!() .arg("test_file") @@ -94,7 +93,6 @@ fn test_mknod_character_device_requires_major_and_minor() { .arg("c") .arg("1") .fails() - .status_code(1) .stderr_contains(&"Invalid value for ''"); } @@ -104,7 +102,6 @@ fn test_mknod_invalid_arg() { new_ucmd!() .arg("--foo") .fails() - .status_code(1) .no_stdout() .stderr_contains(&"Found argument '--foo' which wasn't expected"); }