diff --git a/src/uu/chcon/src/chcon.rs b/src/uu/chcon/src/chcon.rs index 7f1d64d60..e80293f4d 100644 --- a/src/uu/chcon/src/chcon.rs +++ b/src/uu/chcon/src/chcon.rs @@ -2,6 +2,7 @@ #![allow(clippy::upper_case_acronyms)] +use clap::builder::ValueParser; use uucore::error::{UResult, USimpleError, UUsageError}; use uucore::format_usage; use uucore::{display::Quotable, show_error, show_warning}; @@ -203,7 +204,7 @@ pub fn uu_app<'a>() -> Command<'a> { "Use security context of RFILE, rather than specifying \ a CONTEXT value.", ) - .allow_invalid_utf8(true), + .value_parser(ValueParser::os_string()), ) .arg( Arg::new(options::USER) @@ -213,7 +214,7 @@ pub fn uu_app<'a>() -> Command<'a> { .value_name("USER") .value_hint(clap::ValueHint::Username) .help("Set user USER in the target security context.") - .allow_invalid_utf8(true), + .value_parser(ValueParser::os_string()), ) .arg( Arg::new(options::ROLE) @@ -222,7 +223,7 @@ pub fn uu_app<'a>() -> Command<'a> { .takes_value(true) .value_name("ROLE") .help("Set role ROLE in the target security context.") - .allow_invalid_utf8(true), + .value_parser(ValueParser::os_string()), ) .arg( Arg::new(options::TYPE) @@ -231,7 +232,7 @@ pub fn uu_app<'a>() -> Command<'a> { .takes_value(true) .value_name("TYPE") .help("Set type TYPE in the target security context.") - .allow_invalid_utf8(true), + .value_parser(ValueParser::os_string()), ) .arg( Arg::new(options::RANGE) @@ -240,7 +241,7 @@ pub fn uu_app<'a>() -> Command<'a> { .takes_value(true) .value_name("RANGE") .help("Set range RANGE in the target security context.") - .allow_invalid_utf8(true), + .value_parser(ValueParser::os_string()), ) .arg( Arg::new(options::RECURSIVE) @@ -298,7 +299,7 @@ pub fn uu_app<'a>() -> Command<'a> { .multiple_occurrences(true) .value_hint(clap::ValueHint::FilePath) .min_values(1) - .allow_invalid_utf8(true), + .value_parser(ValueParser::os_string()), ) } diff --git a/src/uu/df/src/df.rs b/src/uu/df/src/df.rs index 425a5bb0e..6abf93366 100644 --- a/src/uu/df/src/df.rs +++ b/src/uu/df/src/df.rs @@ -12,6 +12,7 @@ mod filesystem; mod table; use blocks::HumanReadable; +use clap::builder::ValueParser; use table::HeaderMode; use uucore::display::Quotable; use uucore::error::FromIo; @@ -585,7 +586,7 @@ pub fn uu_app<'a>() -> Command<'a> { Arg::new(OPT_TYPE) .short('t') .long("type") - .allow_invalid_utf8(true) + .value_parser(ValueParser::os_string()) .takes_value(true) .value_name("TYPE") .multiple_occurrences(true) @@ -602,7 +603,7 @@ pub fn uu_app<'a>() -> Command<'a> { Arg::new(OPT_EXCLUDE_TYPE) .short('x') .long("exclude-type") - .allow_invalid_utf8(true) + .value_parser(ValueParser::os_string()) .takes_value(true) .value_name("TYPE") .use_value_delimiter(true) diff --git a/src/uu/hashsum/src/hashsum.rs b/src/uu/hashsum/src/hashsum.rs index a2a33561f..d0556bacc 100644 --- a/src/uu/hashsum/src/hashsum.rs +++ b/src/uu/hashsum/src/hashsum.rs @@ -20,6 +20,7 @@ mod digest; use self::digest::Digest; use self::digest::DigestWriter; +use clap::builder::ValueParser; use clap::{Arg, ArgMatches, Command}; use hex::encode; use md5::Md5; @@ -392,7 +393,7 @@ pub fn uu_app_common<'a>() -> Command<'a> { .multiple_occurrences(true) .value_name("FILE") .value_hint(clap::ValueHint::FilePath) - .allow_invalid_utf8(true), + .value_parser(ValueParser::os_string()), ) } diff --git a/src/uu/hostname/src/hostname.rs b/src/uu/hostname/src/hostname.rs index f6f31156a..404b08ffd 100644 --- a/src/uu/hostname/src/hostname.rs +++ b/src/uu/hostname/src/hostname.rs @@ -11,6 +11,7 @@ use std::net::ToSocketAddrs; use std::str; use std::{collections::hash_set::HashSet, ffi::OsString}; +use clap::builder::ValueParser; use clap::{crate_version, Arg, ArgMatches, Command}; use uucore::{ @@ -107,7 +108,7 @@ pub fn uu_app<'a>() -> Command<'a> { ) .arg( Arg::new(OPT_HOST) - .allow_invalid_utf8(true) + .value_parser(ValueParser::os_string()) .value_hint(clap::ValueHint::Hostname), ) } diff --git a/src/uu/join/src/join.rs b/src/uu/join/src/join.rs index 8a7ef5a8e..665baf16a 100644 --- a/src/uu/join/src/join.rs +++ b/src/uu/join/src/join.rs @@ -10,6 +10,7 @@ #[macro_use] extern crate uucore; +use clap::builder::ValueParser; use clap::{crate_version, Arg, Command}; use memchr::{memchr3_iter, memchr_iter}; use std::cmp::Ordering; @@ -762,7 +763,7 @@ FILENUM is 1 or 2, corresponding to FILE1 or FILE2", .short('t') .takes_value(true) .value_name("CHAR") - .allow_invalid_utf8(true) + .value_parser(ValueParser::os_string()) .help("use CHAR as input and output field separator"), ) .arg( diff --git a/src/uu/link/src/link.rs b/src/uu/link/src/link.rs index fe83a55f6..9768e467e 100644 --- a/src/uu/link/src/link.rs +++ b/src/uu/link/src/link.rs @@ -1,3 +1,4 @@ +use clap::builder::ValueParser; // * This file is part of the uutils coreutils package. // * // * (c) Michael Gehring @@ -48,6 +49,6 @@ pub fn uu_app<'a>() -> Command<'a> { .max_values(2) .takes_value(true) .value_hint(clap::ValueHint::AnyPath) - .allow_invalid_utf8(true), + .value_parser(ValueParser::os_string()), ) } diff --git a/src/uu/ls/src/ls.rs b/src/uu/ls/src/ls.rs index 474449d9d..6291a29f0 100644 --- a/src/uu/ls/src/ls.rs +++ b/src/uu/ls/src/ls.rs @@ -10,7 +10,7 @@ #[macro_use] extern crate uucore; -use clap::{crate_version, Arg, Command}; +use clap::{builder::ValueParser, crate_version, Arg, Command}; use glob::Pattern; use lscolors::LsColors; use number_prefix::NumberPrefix; @@ -1536,7 +1536,7 @@ pub fn uu_app<'a>() -> Command<'a> { .multiple_occurrences(true) .takes_value(true) .value_hint(clap::ValueHint::AnyPath) - .allow_invalid_utf8(true) + .value_parser(ValueParser::os_string()) ) .after_help( "The TIME_STYLE argument can be full-iso, long-iso, iso. \ diff --git a/src/uu/mkdir/src/mkdir.rs b/src/uu/mkdir/src/mkdir.rs index b66537b2f..24261c485 100644 --- a/src/uu/mkdir/src/mkdir.rs +++ b/src/uu/mkdir/src/mkdir.rs @@ -10,6 +10,7 @@ #[macro_use] extern crate uucore; +use clap::builder::ValueParser; use clap::parser::ValuesRef; use clap::{crate_version, Arg, ArgMatches, Command}; use std::ffi::OsString; @@ -139,7 +140,7 @@ pub fn uu_app<'a>() -> Command<'a> { .multiple_occurrences(true) .takes_value(true) .min_values(1) - .allow_invalid_utf8(true) + .value_parser(ValueParser::os_string()) .value_hint(clap::ValueHint::DirPath), ) } diff --git a/src/uu/mv/src/mv.rs b/src/uu/mv/src/mv.rs index 63d20e93f..8d0dbe93d 100644 --- a/src/uu/mv/src/mv.rs +++ b/src/uu/mv/src/mv.rs @@ -13,6 +13,7 @@ mod error; #[macro_use] extern crate uucore; +use clap::builder::ValueParser; use clap::{crate_version, Arg, ArgMatches, Command, ErrorKind}; use std::env; use std::ffi::OsString; @@ -172,7 +173,7 @@ pub fn uu_app<'a>() -> Command<'a> { .value_name("DIRECTORY") .value_hint(clap::ValueHint::DirPath) .conflicts_with(OPT_NO_TARGET_DIRECTORY) - .allow_invalid_utf8(true), + .value_parser(ValueParser::os_string()), ) .arg( Arg::new(OPT_NO_TARGET_DIRECTORY) @@ -196,7 +197,7 @@ pub fn uu_app<'a>() -> Command<'a> { .takes_value(true) .min_values(1) .required(true) - .allow_invalid_utf8(true) + .value_parser(ValueParser::os_string()) .value_hint(clap::ValueHint::AnyPath), ) } diff --git a/src/uu/rmdir/src/rmdir.rs b/src/uu/rmdir/src/rmdir.rs index 76c439d96..c13503222 100644 --- a/src/uu/rmdir/src/rmdir.rs +++ b/src/uu/rmdir/src/rmdir.rs @@ -10,6 +10,7 @@ #[macro_use] extern crate uucore; +use clap::builder::ValueParser; use clap::{crate_version, Arg, Command}; use std::ffi::OsString; use std::fs::{read_dir, remove_dir}; @@ -195,7 +196,7 @@ pub fn uu_app<'a>() -> Command<'a> { .takes_value(true) .min_values(1) .required(true) - .allow_invalid_utf8(true) + .value_parser(ValueParser::os_string()) .value_hint(clap::ValueHint::DirPath), ) } diff --git a/src/uu/runcon/src/runcon.rs b/src/uu/runcon/src/runcon.rs index 4de200d03..47f56a148 100644 --- a/src/uu/runcon/src/runcon.rs +++ b/src/uu/runcon/src/runcon.rs @@ -1,5 +1,6 @@ // spell-checker:ignore (vars) RFILE +use clap::builder::ValueParser; use uucore::error::{UResult, UUsageError}; use clap::{Arg, Command}; @@ -124,7 +125,7 @@ pub fn uu_app<'a>() -> Command<'a> { .takes_value(true) .value_name("USER") .help("Set user USER in the target security context.") - .allow_invalid_utf8(true), + .value_parser(ValueParser::os_string()), ) .arg( Arg::new(options::ROLE) @@ -133,7 +134,7 @@ pub fn uu_app<'a>() -> Command<'a> { .takes_value(true) .value_name("ROLE") .help("Set role ROLE in the target security context.") - .allow_invalid_utf8(true), + .value_parser(ValueParser::os_string()), ) .arg( Arg::new(options::TYPE) @@ -142,7 +143,7 @@ pub fn uu_app<'a>() -> Command<'a> { .takes_value(true) .value_name("TYPE") .help("Set type TYPE in the target security context.") - .allow_invalid_utf8(true), + .value_parser(ValueParser::os_string()), ) .arg( Arg::new(options::RANGE) @@ -151,12 +152,12 @@ pub fn uu_app<'a>() -> Command<'a> { .takes_value(true) .value_name("RANGE") .help("Set range RANGE in the target security context.") - .allow_invalid_utf8(true), + .value_parser(ValueParser::os_string()), ) .arg( Arg::new("ARG") .multiple_occurrences(true) - .allow_invalid_utf8(true) + .value_parser(ValueParser::os_string()) .value_hint(clap::ValueHint::CommandName), ) // Once "ARG" is parsed, everything after that belongs to it. diff --git a/src/uu/sort/src/sort.rs b/src/uu/sort/src/sort.rs index d6a44fde1..c315c6e47 100644 --- a/src/uu/sort/src/sort.rs +++ b/src/uu/sort/src/sort.rs @@ -25,6 +25,7 @@ mod numeric_str_cmp; mod tmp_dir; use chunks::LineData; +use clap::builder::ValueParser; use clap::{crate_version, Arg, Command}; use custom_str_cmp::custom_str_cmp; use ext_sort::ext_sort; @@ -1437,7 +1438,7 @@ pub fn uu_app<'a>() -> Command<'a> { .long(options::SEPARATOR) .help("custom separator for -k") .takes_value(true) - .allow_invalid_utf8(true), + .value_parser(ValueParser::os_string()), ) .arg( Arg::new(options::ZERO_TERMINATED) @@ -1489,7 +1490,7 @@ pub fn uu_app<'a>() -> Command<'a> { .takes_value(true) .value_name("NUL_FILES") .multiple_occurrences(true) - .allow_invalid_utf8(true) + .value_parser(ValueParser::os_string()) .value_hint(clap::ValueHint::FilePath), ) .arg( @@ -1501,7 +1502,7 @@ pub fn uu_app<'a>() -> Command<'a> { Arg::new(options::FILES) .multiple_occurrences(true) .takes_value(true) - .allow_invalid_utf8(true) + .value_parser(ValueParser::os_string()) .value_hint(clap::ValueHint::FilePath), ) } diff --git a/src/uu/stat/src/stat.rs b/src/uu/stat/src/stat.rs index cebb3df37..4502efab8 100644 --- a/src/uu/stat/src/stat.rs +++ b/src/uu/stat/src/stat.rs @@ -7,6 +7,7 @@ #[macro_use] extern crate uucore; +use clap::builder::ValueParser; use uucore::display::Quotable; use uucore::error::{FromIo, UResult, USimpleError}; use uucore::fs::display_permissions; @@ -1043,7 +1044,7 @@ pub fn uu_app<'a>() -> Command<'a> { Arg::new(ARG_FILES) .multiple_occurrences(true) .takes_value(true) - .allow_invalid_utf8(true) + .value_parser(ValueParser::os_string()) .min_values(1) .value_hint(clap::ValueHint::FilePath), ) diff --git a/src/uu/touch/src/touch.rs b/src/uu/touch/src/touch.rs index f5f39ec0b..dff59a38c 100644 --- a/src/uu/touch/src/touch.rs +++ b/src/uu/touch/src/touch.rs @@ -12,6 +12,7 @@ pub extern crate filetime; #[macro_use] extern crate uucore; +use clap::builder::ValueParser; use clap::{crate_version, Arg, ArgGroup, Command}; use filetime::*; use std::ffi::OsString; @@ -227,7 +228,7 @@ pub fn uu_app<'a>() -> Command<'a> { .long(options::sources::REFERENCE) .help("use this file's times instead of the current time") .value_name("FILE") - .allow_invalid_utf8(true) + .value_parser(ValueParser::os_string()) .value_hint(clap::ValueHint::AnyPath), ) .arg( @@ -247,7 +248,7 @@ pub fn uu_app<'a>() -> Command<'a> { .multiple_occurrences(true) .takes_value(true) .min_values(1) - .allow_invalid_utf8(true) + .value_parser(ValueParser::os_string()) .value_hint(clap::ValueHint::AnyPath), ) .group(ArgGroup::new(options::SOURCES).args(&[ diff --git a/src/uu/unlink/src/unlink.rs b/src/uu/unlink/src/unlink.rs index 55a2f9ce5..2e12ba4f1 100644 --- a/src/uu/unlink/src/unlink.rs +++ b/src/uu/unlink/src/unlink.rs @@ -11,6 +11,7 @@ use std::ffi::OsString; use std::fs::remove_file; use std::path::Path; +use clap::builder::ValueParser; use clap::{crate_version, Arg, Command}; use uucore::display::Quotable; @@ -37,7 +38,7 @@ pub fn uu_app<'a>() -> Command<'a> { Arg::new(OPT_PATH) .required(true) .hide(true) - .allow_invalid_utf8(true) + .value_parser(ValueParser::os_string()) .value_hint(clap::ValueHint::AnyPath), ) } diff --git a/src/uu/wc/src/wc.rs b/src/uu/wc/src/wc.rs index cc33df575..ef3b40c91 100644 --- a/src/uu/wc/src/wc.rs +++ b/src/uu/wc/src/wc.rs @@ -13,6 +13,7 @@ extern crate uucore; mod count_fast; mod countable; mod word_count; +use clap::builder::ValueParser; use count_fast::{count_bytes_chars_and_lines_fast, count_bytes_fast}; use countable::WordCountable; use unicode_width::UnicodeWidthChar; @@ -256,7 +257,7 @@ pub fn uu_app<'a>() -> Command<'a> { Arg::new(ARG_FILES) .multiple_occurrences(true) .takes_value(true) - .allow_invalid_utf8(true) + .value_parser(ValueParser::os_string()) .value_hint(clap::ValueHint::FilePath), ) }