From 3c6400317a94596f90cc849c4a13b64f06601b87 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Sat, 20 Aug 2022 10:29:41 +0200 Subject: [PATCH] Replace deprecated value_of_os() with get_one() --- src/uu/chcon/src/chcon.rs | 10 +++++----- src/uu/hostname/src/hostname.rs | 4 ++-- src/uu/join/src/join.rs | 3 ++- src/uu/mv/src/mv.rs | 2 +- src/uu/runcon/src/runcon.rs | 8 ++++---- src/uu/sort/src/sort.rs | 2 +- src/uu/touch/src/touch.rs | 2 +- src/uu/unlink/src/unlink.rs | 3 ++- 8 files changed, 18 insertions(+), 16 deletions(-) diff --git a/src/uu/chcon/src/chcon.rs b/src/uu/chcon/src/chcon.rs index 7b72fd41a..fbfdbc31f 100644 --- a/src/uu/chcon/src/chcon.rs +++ b/src/uu/chcon/src/chcon.rs @@ -359,7 +359,7 @@ fn parse_command_line(config: clap::Command, args: impl uucore::Args) -> Result< let mut files = matches.get_many::("FILE").unwrap_or_default(); - let mode = if let Some(path) = matches.value_of_os(options::REFERENCE) { + let mode = if let Some(path) = matches.get_one::(options::REFERENCE) { CommandLineMode::ReferenceBased { reference: PathBuf::from(path), } @@ -369,10 +369,10 @@ fn parse_command_line(config: clap::Command, args: impl uucore::Args) -> Result< || matches.contains_id(options::RANGE) { CommandLineMode::Custom { - user: matches.value_of_os(options::USER).map(Into::into), - role: matches.value_of_os(options::ROLE).map(Into::into), - the_type: matches.value_of_os(options::TYPE).map(Into::into), - range: matches.value_of_os(options::RANGE).map(Into::into), + user: matches.get_one::(options::USER).map(Into::into), + role: matches.get_one::(options::ROLE).map(Into::into), + the_type: matches.get_one::(options::TYPE).map(Into::into), + range: matches.get_one::(options::RANGE).map(Into::into), } } else if let Some(context) = files.next() { CommandLineMode::ContextBased { diff --git a/src/uu/hostname/src/hostname.rs b/src/uu/hostname/src/hostname.rs index ad8e0479f..f6f31156a 100644 --- a/src/uu/hostname/src/hostname.rs +++ b/src/uu/hostname/src/hostname.rs @@ -7,9 +7,9 @@ // spell-checker:ignore (ToDO) MAKEWORD addrs hashset -use std::collections::hash_set::HashSet; use std::net::ToSocketAddrs; use std::str; +use std::{collections::hash_set::HashSet, ffi::OsString}; use clap::{crate_version, Arg, ArgMatches, Command}; @@ -65,7 +65,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { #[cfg(windows)] let _handle = wsa::start().map_err_context(|| "failed to start Winsock".to_owned())?; - match matches.value_of_os(OPT_HOST) { + match matches.get_one::(OPT_HOST) { None => display_hostname(&matches), Some(host) => hostname::set(host).map_err_context(|| "failed to set hostname".to_owned()), } diff --git a/src/uu/join/src/join.rs b/src/uu/join/src/join.rs index a987a1744..8a7ef5a8e 100644 --- a/src/uu/join/src/join.rs +++ b/src/uu/join/src/join.rs @@ -15,6 +15,7 @@ use memchr::{memchr3_iter, memchr_iter}; use std::cmp::Ordering; use std::convert::From; use std::error::Error; +use std::ffi::OsString; use std::fmt::Display; use std::fs::File; use std::io::{stdin, stdout, BufRead, BufReader, BufWriter, Split, Stdin, Write}; @@ -627,7 +628,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { settings.key1 = get_field_number(keys, key1)?; settings.key2 = get_field_number(keys, key2)?; - if let Some(value_os) = matches.value_of_os("t") { + if let Some(value_os) = matches.get_one::("t") { #[cfg(unix)] let value = value_os.as_bytes(); #[cfg(not(unix))] diff --git a/src/uu/mv/src/mv.rs b/src/uu/mv/src/mv.rs index a29b8fca9..1e76d090f 100644 --- a/src/uu/mv/src/mv.rs +++ b/src/uu/mv/src/mv.rs @@ -115,7 +115,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { suffix: backup_suffix, update: matches.contains_id(OPT_UPDATE), target_dir: matches - .value_of_os(OPT_TARGET_DIRECTORY) + .get_one::(OPT_TARGET_DIRECTORY) .map(OsString::from), no_target_dir: matches.contains_id(OPT_NO_TARGET_DIRECTORY), verbose: matches.contains_id(OPT_VERBOSE), diff --git a/src/uu/runcon/src/runcon.rs b/src/uu/runcon/src/runcon.rs index 6035d049c..4de200d03 100644 --- a/src/uu/runcon/src/runcon.rs +++ b/src/uu/runcon/src/runcon.rs @@ -226,10 +226,10 @@ fn parse_command_line(config: Command, args: impl uucore::Args) -> Result