From 62b1b7cfb271252174d0dba70184254da0ed8b23 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Sat, 20 Aug 2022 08:19:11 +0200 Subject: [PATCH] Replace deprecated values_of_os() with get_many() --- src/uu/chcon/src/chcon.rs | 2 +- src/uu/dir/src/dir.rs | 3 ++- src/uu/hashsum/src/hashsum.rs | 4 ++-- src/uu/link/src/link.rs | 3 ++- src/uu/ls/src/ls.rs | 2 +- src/uu/mkdir/src/mkdir.rs | 10 +++++++--- src/uu/mv/src/mv.rs | 2 +- src/uu/rmdir/src/rmdir.rs | 3 ++- src/uu/runcon/src/runcon.rs | 2 +- src/uu/sort/src/sort.rs | 4 ++-- src/uu/stat/src/stat.rs | 2 +- src/uu/touch/src/touch.rs | 3 ++- src/uu/users/src/users.rs | 3 ++- src/uu/vdir/src/vdir.rs | 3 ++- src/uu/wc/src/wc.rs | 6 +++--- 15 files changed, 31 insertions(+), 21 deletions(-) diff --git a/src/uu/chcon/src/chcon.rs b/src/uu/chcon/src/chcon.rs index ee6f6e598..7b72fd41a 100644 --- a/src/uu/chcon/src/chcon.rs +++ b/src/uu/chcon/src/chcon.rs @@ -357,7 +357,7 @@ fn parse_command_line(config: clap::Command, args: impl uucore::Args) -> Result< // By default, do not preserve root. let preserve_root = matches.contains_id(options::preserve_root::PRESERVE_ROOT); - let mut files = matches.values_of_os("FILE").unwrap_or_default(); + let mut files = matches.get_many::("FILE").unwrap_or_default(); let mode = if let Some(path) = matches.value_of_os(options::REFERENCE) { CommandLineMode::ReferenceBased { diff --git a/src/uu/dir/src/dir.rs b/src/uu/dir/src/dir.rs index 2f51395f2..22932d9ae 100644 --- a/src/uu/dir/src/dir.rs +++ b/src/uu/dir/src/dir.rs @@ -6,6 +6,7 @@ // * that was distributed with this source code. use clap::Command; +use std::ffi::OsString; use std::path::Path; use uu_ls::{options, Config, Format}; use uucore::error::UResult; @@ -55,7 +56,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { } let locs = matches - .values_of_os(options::PATHS) + .get_many::(options::PATHS) .map(|v| v.map(Path::new).collect()) .unwrap_or_else(|| vec![Path::new(".")]); diff --git a/src/uu/hashsum/src/hashsum.rs b/src/uu/hashsum/src/hashsum.rs index 3d8ba8d41..a2a33561f 100644 --- a/src/uu/hashsum/src/hashsum.rs +++ b/src/uu/hashsum/src/hashsum.rs @@ -320,8 +320,8 @@ pub fn uumain(mut args: impl uucore::Args) -> UResult<()> { warn, }; - match matches.values_of_os("FILE") { - Some(files) => hashsum(opts, files), + match matches.get_many::("FILE") { + Some(files) => hashsum(opts, files.map(|f| f.as_os_str())), None => hashsum(opts, iter::once(OsStr::new("-"))), } } diff --git a/src/uu/link/src/link.rs b/src/uu/link/src/link.rs index 1fc0c49ce..fe83a55f6 100644 --- a/src/uu/link/src/link.rs +++ b/src/uu/link/src/link.rs @@ -5,6 +5,7 @@ // * For the full copyright and license information, please view the LICENSE // * file that was distributed with this source code. use clap::{crate_version, Arg, Command}; +use std::ffi::OsString; use std::fs::hard_link; use std::path::Path; use uucore::display::Quotable; @@ -23,7 +24,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { let matches = uu_app().get_matches_from(args); let files: Vec<_> = matches - .values_of_os(options::FILES) + .get_many::(options::FILES) .unwrap_or_default() .collect(); let old = Path::new(files[0]); diff --git a/src/uu/ls/src/ls.rs b/src/uu/ls/src/ls.rs index 9a3f6ac89..dada67f21 100644 --- a/src/uu/ls/src/ls.rs +++ b/src/uu/ls/src/ls.rs @@ -898,7 +898,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { let config = Config::from(&matches)?; let locs = matches - .values_of_os(options::PATHS) + .get_many::(options::PATHS) .map(|v| v.map(Path::new).collect()) .unwrap_or_else(|| vec![Path::new(".")]); diff --git a/src/uu/mkdir/src/mkdir.rs b/src/uu/mkdir/src/mkdir.rs index 3f7cbf1b9..b66537b2f 100644 --- a/src/uu/mkdir/src/mkdir.rs +++ b/src/uu/mkdir/src/mkdir.rs @@ -10,7 +10,9 @@ #[macro_use] extern crate uucore; -use clap::{crate_version, Arg, ArgMatches, Command, OsValues}; +use clap::parser::ValuesRef; +use clap::{crate_version, Arg, ArgMatches, Command}; +use std::ffi::OsString; use std::path::{Path, PathBuf}; #[cfg(not(windows))] use uucore::error::FromIo; @@ -95,7 +97,9 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { // " of each created directory to CTX"), let matches = uu_app().after_help(&after_help[..]).get_matches_from(args); - let dirs = matches.values_of_os(options::DIRS).unwrap_or_default(); + let dirs = matches + .get_many::(options::DIRS) + .unwrap_or_default(); let verbose = matches.contains_id(options::VERBOSE); let recursive = matches.contains_id(options::PARENTS); @@ -143,7 +147,7 @@ pub fn uu_app<'a>() -> Command<'a> { /** * Create the list of new directories */ -fn exec(dirs: OsValues, recursive: bool, mode: u32, verbose: bool) -> UResult<()> { +fn exec(dirs: ValuesRef, recursive: bool, mode: u32, verbose: bool) -> UResult<()> { for dir in dirs { // Special case to match GNU's behavior: // mkdir -p foo/. should work and just create foo/ diff --git a/src/uu/mv/src/mv.rs b/src/uu/mv/src/mv.rs index 8a681704f..a29b8fca9 100644 --- a/src/uu/mv/src/mv.rs +++ b/src/uu/mv/src/mv.rs @@ -92,7 +92,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { } let files: Vec = matches - .values_of_os(ARG_FILES) + .get_many::(ARG_FILES) .unwrap_or_default() .map(|v| v.to_os_string()) .collect(); diff --git a/src/uu/rmdir/src/rmdir.rs b/src/uu/rmdir/src/rmdir.rs index e4ff74ddf..76c439d96 100644 --- a/src/uu/rmdir/src/rmdir.rs +++ b/src/uu/rmdir/src/rmdir.rs @@ -11,6 +11,7 @@ extern crate uucore; use clap::{crate_version, Arg, Command}; +use std::ffi::OsString; use std::fs::{read_dir, remove_dir}; use std::io; use std::path::Path; @@ -40,7 +41,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { }; for path in matches - .values_of_os(ARG_DIRS) + .get_many::(ARG_DIRS) .unwrap_or_default() .map(Path::new) { diff --git a/src/uu/runcon/src/runcon.rs b/src/uu/runcon/src/runcon.rs index 31858d3f7..6035d049c 100644 --- a/src/uu/runcon/src/runcon.rs +++ b/src/uu/runcon/src/runcon.rs @@ -212,7 +212,7 @@ fn parse_command_line(config: Command, args: impl uucore::Args) -> Result