mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-27 19:17:43 +00:00
Replace deprecated value_of_os() with get_one()
This commit is contained in:
parent
8786bb6541
commit
3c6400317a
8 changed files with 18 additions and 16 deletions
|
@ -359,7 +359,7 @@ fn parse_command_line(config: clap::Command, args: impl uucore::Args) -> Result<
|
||||||
|
|
||||||
let mut files = matches.get_many::<PathBuf>("FILE").unwrap_or_default();
|
let mut files = matches.get_many::<PathBuf>("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::<OsString>(options::REFERENCE) {
|
||||||
CommandLineMode::ReferenceBased {
|
CommandLineMode::ReferenceBased {
|
||||||
reference: PathBuf::from(path),
|
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)
|
|| matches.contains_id(options::RANGE)
|
||||||
{
|
{
|
||||||
CommandLineMode::Custom {
|
CommandLineMode::Custom {
|
||||||
user: matches.value_of_os(options::USER).map(Into::into),
|
user: matches.get_one::<OsString>(options::USER).map(Into::into),
|
||||||
role: matches.value_of_os(options::ROLE).map(Into::into),
|
role: matches.get_one::<OsString>(options::ROLE).map(Into::into),
|
||||||
the_type: matches.value_of_os(options::TYPE).map(Into::into),
|
the_type: matches.get_one::<OsString>(options::TYPE).map(Into::into),
|
||||||
range: matches.value_of_os(options::RANGE).map(Into::into),
|
range: matches.get_one::<OsString>(options::RANGE).map(Into::into),
|
||||||
}
|
}
|
||||||
} else if let Some(context) = files.next() {
|
} else if let Some(context) = files.next() {
|
||||||
CommandLineMode::ContextBased {
|
CommandLineMode::ContextBased {
|
||||||
|
|
|
@ -7,9 +7,9 @@
|
||||||
|
|
||||||
// spell-checker:ignore (ToDO) MAKEWORD addrs hashset
|
// spell-checker:ignore (ToDO) MAKEWORD addrs hashset
|
||||||
|
|
||||||
use std::collections::hash_set::HashSet;
|
|
||||||
use std::net::ToSocketAddrs;
|
use std::net::ToSocketAddrs;
|
||||||
use std::str;
|
use std::str;
|
||||||
|
use std::{collections::hash_set::HashSet, ffi::OsString};
|
||||||
|
|
||||||
use clap::{crate_version, Arg, ArgMatches, Command};
|
use clap::{crate_version, Arg, ArgMatches, Command};
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
let _handle = wsa::start().map_err_context(|| "failed to start Winsock".to_owned())?;
|
let _handle = wsa::start().map_err_context(|| "failed to start Winsock".to_owned())?;
|
||||||
|
|
||||||
match matches.value_of_os(OPT_HOST) {
|
match matches.get_one::<OsString>(OPT_HOST) {
|
||||||
None => display_hostname(&matches),
|
None => display_hostname(&matches),
|
||||||
Some(host) => hostname::set(host).map_err_context(|| "failed to set hostname".to_owned()),
|
Some(host) => hostname::set(host).map_err_context(|| "failed to set hostname".to_owned()),
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@ use memchr::{memchr3_iter, memchr_iter};
|
||||||
use std::cmp::Ordering;
|
use std::cmp::Ordering;
|
||||||
use std::convert::From;
|
use std::convert::From;
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
|
use std::ffi::OsString;
|
||||||
use std::fmt::Display;
|
use std::fmt::Display;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::{stdin, stdout, BufRead, BufReader, BufWriter, Split, Stdin, Write};
|
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.key1 = get_field_number(keys, key1)?;
|
||||||
settings.key2 = get_field_number(keys, key2)?;
|
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::<OsString>("t") {
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
let value = value_os.as_bytes();
|
let value = value_os.as_bytes();
|
||||||
#[cfg(not(unix))]
|
#[cfg(not(unix))]
|
||||||
|
|
|
@ -115,7 +115,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
suffix: backup_suffix,
|
suffix: backup_suffix,
|
||||||
update: matches.contains_id(OPT_UPDATE),
|
update: matches.contains_id(OPT_UPDATE),
|
||||||
target_dir: matches
|
target_dir: matches
|
||||||
.value_of_os(OPT_TARGET_DIRECTORY)
|
.get_one::<OsString>(OPT_TARGET_DIRECTORY)
|
||||||
.map(OsString::from),
|
.map(OsString::from),
|
||||||
no_target_dir: matches.contains_id(OPT_NO_TARGET_DIRECTORY),
|
no_target_dir: matches.contains_id(OPT_NO_TARGET_DIRECTORY),
|
||||||
verbose: matches.contains_id(OPT_VERBOSE),
|
verbose: matches.contains_id(OPT_VERBOSE),
|
||||||
|
|
|
@ -226,10 +226,10 @@ fn parse_command_line(config: Command, args: impl uucore::Args) -> Result<Option
|
||||||
|
|
||||||
let mode = CommandLineMode::CustomContext {
|
let mode = CommandLineMode::CustomContext {
|
||||||
compute_transition_context,
|
compute_transition_context,
|
||||||
user: matches.value_of_os(options::USER).map(Into::into),
|
user: matches.get_one::<OsString>(options::USER).map(Into::into),
|
||||||
role: matches.value_of_os(options::ROLE).map(Into::into),
|
role: matches.get_one::<OsString>(options::ROLE).map(Into::into),
|
||||||
the_type: matches.value_of_os(options::TYPE).map(Into::into),
|
the_type: matches.get_one::<OsString>(options::TYPE).map(Into::into),
|
||||||
range: matches.value_of_os(options::RANGE).map(Into::into),
|
range: matches.get_one::<OsString>(options::RANGE).map(Into::into),
|
||||||
command: args.next(),
|
command: args.next(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1201,7 +1201,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(arg) = matches.value_of_os(options::SEPARATOR) {
|
if let Some(arg) = matches.get_one::<OsString>(options::SEPARATOR) {
|
||||||
let mut separator = arg.to_str().ok_or_else(|| {
|
let mut separator = arg.to_str().ok_or_else(|| {
|
||||||
UUsageError::new(
|
UUsageError::new(
|
||||||
2,
|
2,
|
||||||
|
|
|
@ -78,7 +78,7 @@ Try 'touch --help' for more information."##,
|
||||||
)
|
)
|
||||||
})?;
|
})?;
|
||||||
let (mut atime, mut mtime) =
|
let (mut atime, mut mtime) =
|
||||||
if let Some(reference) = matches.value_of_os(options::sources::REFERENCE) {
|
if let Some(reference) = matches.get_one::<OsString>(options::sources::REFERENCE) {
|
||||||
stat(
|
stat(
|
||||||
Path::new(reference),
|
Path::new(reference),
|
||||||
!matches.contains_id(options::NO_DEREF),
|
!matches.contains_id(options::NO_DEREF),
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
|
|
||||||
/* last synced with: unlink (GNU coreutils) 8.21 */
|
/* last synced with: unlink (GNU coreutils) 8.21 */
|
||||||
|
|
||||||
|
use std::ffi::OsString;
|
||||||
use std::fs::remove_file;
|
use std::fs::remove_file;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
|
@ -22,7 +23,7 @@ static OPT_PATH: &str = "FILE";
|
||||||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
let matches = uu_app().get_matches_from(args);
|
let matches = uu_app().get_matches_from(args);
|
||||||
|
|
||||||
let path: &Path = matches.value_of_os(OPT_PATH).unwrap().as_ref();
|
let path: &Path = matches.get_one::<OsString>(OPT_PATH).unwrap().as_ref();
|
||||||
|
|
||||||
remove_file(path).map_err_context(|| format!("cannot unlink {}", path.quote()))
|
remove_file(path).map_err_context(|| format!("cannot unlink {}", path.quote()))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue