mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
change remaining usage codes of 2 to 1 for GNU compat
This commit is contained in:
parent
70714bc3cd
commit
975a1d170d
74 changed files with 121 additions and 99 deletions
|
@ -16,7 +16,7 @@ static SUMMARY: &str = "Determine architecture name for current machine.";
|
||||||
|
|
||||||
#[uucore::main]
|
#[uucore::main]
|
||||||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
uu_app().get_matches_from(args);
|
uu_app().try_get_matches_from(args)?;
|
||||||
|
|
||||||
let uts = PlatformInfo::new().map_err_context(|| "cannot get system name".to_string())?;
|
let uts = PlatformInfo::new().map_err_context(|| "cannot get system name".to_string())?;
|
||||||
println!("{}", uts.machine().trim());
|
println!("{}", uts.machine().trim());
|
||||||
|
|
|
@ -49,7 +49,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
//
|
//
|
||||||
// Argument parsing
|
// Argument parsing
|
||||||
//
|
//
|
||||||
let matches = uu_app().get_matches_from(args);
|
let matches = uu_app().try_get_matches_from(args)?;
|
||||||
|
|
||||||
// too few arguments
|
// too few arguments
|
||||||
if !matches.contains_id(options::NAME) {
|
if !matches.contains_id(options::NAME) {
|
||||||
|
|
|
@ -54,7 +54,9 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
|
|
||||||
let after_help = get_long_usage();
|
let after_help = get_long_usage();
|
||||||
|
|
||||||
let matches = uu_app().after_help(&after_help[..]).get_matches_from(args);
|
let matches = uu_app()
|
||||||
|
.after_help(&after_help[..])
|
||||||
|
.try_get_matches_from(args)?;
|
||||||
|
|
||||||
let changes = matches.contains_id(options::CHANGES);
|
let changes = matches.contains_id(options::CHANGES);
|
||||||
let quiet = matches.contains_id(options::QUIET);
|
let quiet = matches.contains_id(options::QUIET);
|
||||||
|
|
|
@ -15,7 +15,7 @@ use std::ffi::CString;
|
||||||
use std::io::Error;
|
use std::io::Error;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::process;
|
use std::process;
|
||||||
use uucore::error::{set_exit_code, UResult};
|
use uucore::error::{set_exit_code, UClapError, UResult};
|
||||||
use uucore::libc::{self, chroot, setgid, setgroups, setuid};
|
use uucore::libc::{self, chroot, setgid, setgroups, setuid};
|
||||||
use uucore::{entries, format_usage};
|
use uucore::{entries, format_usage};
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ mod options {
|
||||||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
let args = args.collect_lossy();
|
let args = args.collect_lossy();
|
||||||
|
|
||||||
let matches = uu_app().get_matches_from(args);
|
let matches = uu_app().try_get_matches_from(args).with_exit_code(125)?;
|
||||||
|
|
||||||
let default_shell: &'static str = "/bin/sh";
|
let default_shell: &'static str = "/bin/sh";
|
||||||
let default_option: &'static str = "-i";
|
let default_option: &'static str = "-i";
|
||||||
|
|
|
@ -115,7 +115,7 @@ mod options {
|
||||||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
let args = args.collect_ignore();
|
let args = args.collect_ignore();
|
||||||
|
|
||||||
let matches = uu_app().get_matches_from(args);
|
let matches = uu_app().try_get_matches_from(args)?;
|
||||||
|
|
||||||
let files: Vec<String> = match matches.get_many::<String>(options::FILE) {
|
let files: Vec<String> = match matches.get_many::<String>(options::FILE) {
|
||||||
Some(v) => v.clone().map(|v| v.to_owned()).collect(),
|
Some(v) => v.clone().map(|v| v.to_owned()).collect(),
|
||||||
|
|
|
@ -134,7 +134,7 @@ fn open_file(name: &str) -> io::Result<LineReader> {
|
||||||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
let args = args.collect_lossy();
|
let args = args.collect_lossy();
|
||||||
|
|
||||||
let matches = uu_app().get_matches_from(args);
|
let matches = uu_app().try_get_matches_from(args)?;
|
||||||
let filename1 = matches.value_of(options::FILE_1).unwrap();
|
let filename1 = matches.value_of(options::FILE_1).unwrap();
|
||||||
let filename2 = matches.value_of(options::FILE_2).unwrap();
|
let filename2 = matches.value_of(options::FILE_2).unwrap();
|
||||||
let mut f1 = open_file(filename1).map_err_context(|| filename1.to_string())?;
|
let mut f1 = open_file(filename1).map_err_context(|| filename1.to_string())?;
|
||||||
|
|
|
@ -715,7 +715,7 @@ mod tests {
|
||||||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
let args = args.collect_ignore();
|
let args = args.collect_ignore();
|
||||||
|
|
||||||
let matches = uu_app().get_matches_from(args);
|
let matches = uu_app().try_get_matches_from(args)?;
|
||||||
|
|
||||||
// get the file to split
|
// get the file to split
|
||||||
let file_name = matches.value_of(options::FILE).unwrap();
|
let file_name = matches.value_of(options::FILE).unwrap();
|
||||||
|
|
|
@ -401,7 +401,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
let args = args.collect_ignore();
|
let args = args.collect_ignore();
|
||||||
|
|
||||||
let delimiter_is_equal = args.contains(&"-d=".to_string()); // special case
|
let delimiter_is_equal = args.contains(&"-d=".to_string()); // special case
|
||||||
let matches = uu_app().get_matches_from(args);
|
let matches = uu_app().try_get_matches_from(args)?;
|
||||||
|
|
||||||
let complement = matches.contains_id(options::COMPLEMENT);
|
let complement = matches.contains_id(options::COMPLEMENT);
|
||||||
|
|
||||||
|
|
|
@ -144,7 +144,7 @@ impl<'a> From<&'a str> for Rfc3339Format {
|
||||||
|
|
||||||
#[uucore::main]
|
#[uucore::main]
|
||||||
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().try_get_matches_from(args)?;
|
||||||
|
|
||||||
let format = if let Some(form) = matches.value_of(OPT_FORMAT) {
|
let format = if let Some(form) = matches.value_of(OPT_FORMAT) {
|
||||||
if !form.starts_with('+') {
|
if !form.starts_with('+') {
|
||||||
|
|
|
@ -712,7 +712,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
|
|
||||||
let matches = uu_app()
|
let matches = uu_app()
|
||||||
//.after_help(TODO: Add note about multiplier strings here.)
|
//.after_help(TODO: Add note about multiplier strings here.)
|
||||||
.get_matches_from(dashed_args);
|
.try_get_matches_from(dashed_args)?;
|
||||||
|
|
||||||
match (
|
match (
|
||||||
matches.contains_id(options::INFILE),
|
matches.contains_id(options::INFILE),
|
||||||
|
|
|
@ -431,7 +431,7 @@ impl fmt::Display for DfError {
|
||||||
|
|
||||||
#[uucore::main]
|
#[uucore::main]
|
||||||
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().try_get_matches_from(args)?;
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
{
|
{
|
||||||
|
|
|
@ -67,7 +67,7 @@ pub fn guess_syntax() -> OutputFmt {
|
||||||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
let args = args.collect_ignore();
|
let args = args.collect_ignore();
|
||||||
|
|
||||||
let matches = uu_app().get_matches_from(&args);
|
let matches = uu_app().try_get_matches_from(&args)?;
|
||||||
|
|
||||||
let files = matches
|
let files = matches
|
||||||
.get_many::<String>(options::FILE)
|
.get_many::<String>(options::FILE)
|
||||||
|
|
|
@ -32,7 +32,9 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
|
|
||||||
let after_help = get_long_usage();
|
let after_help = get_long_usage();
|
||||||
|
|
||||||
let matches = uu_app().after_help(&after_help[..]).get_matches_from(args);
|
let matches = uu_app()
|
||||||
|
.after_help(&after_help[..])
|
||||||
|
.try_get_matches_from(args)?;
|
||||||
|
|
||||||
let separator = if matches.contains_id(options::ZERO) {
|
let separator = if matches.contains_id(options::ZERO) {
|
||||||
"\0"
|
"\0"
|
||||||
|
|
|
@ -517,7 +517,7 @@ fn build_exclude_patterns(matches: &ArgMatches) -> UResult<Vec<Pattern>> {
|
||||||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
let args = args.collect_ignore();
|
let args = args.collect_ignore();
|
||||||
|
|
||||||
let matches = uu_app().get_matches_from(args);
|
let matches = uu_app().try_get_matches_from(args)?;
|
||||||
|
|
||||||
let summarize = matches.contains_id(options::SUMMARIZE);
|
let summarize = matches.contains_id(options::SUMMARIZE);
|
||||||
|
|
||||||
|
|
4
src/uu/env/src/env.rs
vendored
4
src/uu/env/src/env.rs
vendored
|
@ -26,7 +26,7 @@ use std::iter::Iterator;
|
||||||
use std::os::unix::process::ExitStatusExt;
|
use std::os::unix::process::ExitStatusExt;
|
||||||
use std::process;
|
use std::process;
|
||||||
use uucore::display::Quotable;
|
use uucore::display::Quotable;
|
||||||
use uucore::error::{UResult, USimpleError, UUsageError};
|
use uucore::error::{UClapError, UResult, USimpleError, UUsageError};
|
||||||
use uucore::format_usage;
|
use uucore::format_usage;
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
use uucore::signals::signal_name_by_value;
|
use uucore::signals::signal_name_by_value;
|
||||||
|
@ -173,7 +173,7 @@ pub fn uu_app<'a>() -> Command<'a> {
|
||||||
|
|
||||||
fn run_env(args: impl uucore::Args) -> UResult<()> {
|
fn run_env(args: impl uucore::Args) -> UResult<()> {
|
||||||
let app = uu_app();
|
let app = uu_app();
|
||||||
let matches = app.get_matches_from(args);
|
let matches = app.try_get_matches_from(args).with_exit_code(125)?;
|
||||||
|
|
||||||
let ignore_env = matches.contains_id("ignore-environment");
|
let ignore_env = matches.contains_id("ignore-environment");
|
||||||
let null = matches.contains_id("null");
|
let null = matches.contains_id("null");
|
||||||
|
|
|
@ -271,7 +271,7 @@ fn expand_shortcuts(args: &[String]) -> Vec<String> {
|
||||||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
let args = args.collect_ignore();
|
let args = args.collect_ignore();
|
||||||
|
|
||||||
let matches = uu_app().get_matches_from(expand_shortcuts(&args));
|
let matches = uu_app().try_get_matches_from(expand_shortcuts(&args))?;
|
||||||
|
|
||||||
expand(&Options::new(&matches)?).map_err_context(|| "failed to write output".to_string())
|
expand(&Options::new(&matches)?).map_err_context(|| "failed to write output".to_string())
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,7 @@ fn print_factors_str(
|
||||||
|
|
||||||
#[uucore::main]
|
#[uucore::main]
|
||||||
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().try_get_matches_from(args)?;
|
||||||
let stdout = stdout();
|
let stdout = stdout();
|
||||||
// We use a smaller buffer here to pass a gnu test. 4KiB appears to be the default pipe size for bash.
|
// We use a smaller buffer here to pass a gnu test. 4KiB appears to be the default pipe size for bash.
|
||||||
let mut w = io::BufWriter::with_capacity(4 * 1024, stdout.lock());
|
let mut w = io::BufWriter::with_capacity(4 * 1024, stdout.lock());
|
||||||
|
|
|
@ -67,7 +67,7 @@ pub struct FmtOptions {
|
||||||
#[uucore::main]
|
#[uucore::main]
|
||||||
#[allow(clippy::cognitive_complexity)]
|
#[allow(clippy::cognitive_complexity)]
|
||||||
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().try_get_matches_from(args)?;
|
||||||
|
|
||||||
let mut files: Vec<String> = matches
|
let mut files: Vec<String> = matches
|
||||||
.get_many::<String>(ARG_FILES)
|
.get_many::<String>(ARG_FILES)
|
||||||
|
|
|
@ -34,7 +34,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
let args = args.collect_lossy();
|
let args = args.collect_lossy();
|
||||||
|
|
||||||
let (args, obs_width) = handle_obsolete(&args[..]);
|
let (args, obs_width) = handle_obsolete(&args[..]);
|
||||||
let matches = uu_app().get_matches_from(args);
|
let matches = uu_app().try_get_matches_from(args)?;
|
||||||
|
|
||||||
let bytes = matches.contains_id(options::BYTES);
|
let bytes = matches.contains_id(options::BYTES);
|
||||||
let spaces = matches.contains_id(options::SPACES);
|
let spaces = matches.contains_id(options::SPACES);
|
||||||
|
|
|
@ -70,7 +70,7 @@ fn infallible_gid2grp(gid: &u32) -> String {
|
||||||
|
|
||||||
#[uucore::main]
|
#[uucore::main]
|
||||||
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().try_get_matches_from(args)?;
|
||||||
|
|
||||||
let users: Vec<String> = matches
|
let users: Vec<String> = matches
|
||||||
.get_many::<String>(options::USERS)
|
.get_many::<String>(options::USERS)
|
||||||
|
|
|
@ -284,7 +284,7 @@ pub fn uumain(mut args: impl uucore::Args) -> UResult<()> {
|
||||||
// causes "error: " to be printed twice (once from crash!() and once from clap). With
|
// causes "error: " to be printed twice (once from crash!() and once from clap). With
|
||||||
// the current setup, the name of the utility is not printed, but I think this is at
|
// the current setup, the name of the utility is not printed, but I think this is at
|
||||||
// least somewhat better from a user's perspective.
|
// least somewhat better from a user's perspective.
|
||||||
let matches = command.get_matches_from(args);
|
let matches = command.try_get_matches_from(args)?;
|
||||||
|
|
||||||
let (name, algo, bits) = detect_algo(&binary_name, &matches);
|
let (name, algo, bits) = detect_algo(&binary_name, &matches);
|
||||||
|
|
||||||
|
|
|
@ -154,7 +154,7 @@ impl Mode {
|
||||||
|
|
||||||
fn arg_iterate<'a>(
|
fn arg_iterate<'a>(
|
||||||
mut args: impl uucore::Args + 'a,
|
mut args: impl uucore::Args + 'a,
|
||||||
) -> Result<Box<dyn Iterator<Item = OsString> + 'a>, String> {
|
) -> UResult<Box<dyn Iterator<Item = OsString> + 'a>> {
|
||||||
// argv[0] is always present
|
// argv[0] is always present
|
||||||
let first = args.next().unwrap();
|
let first = args.next().unwrap();
|
||||||
if let Some(second) = args.next() {
|
if let Some(second) = args.next() {
|
||||||
|
@ -162,16 +162,22 @@ fn arg_iterate<'a>(
|
||||||
match parse::parse_obsolete(s) {
|
match parse::parse_obsolete(s) {
|
||||||
Some(Ok(iter)) => Ok(Box::new(vec![first].into_iter().chain(iter).chain(args))),
|
Some(Ok(iter)) => Ok(Box::new(vec![first].into_iter().chain(iter).chain(args))),
|
||||||
Some(Err(e)) => match e {
|
Some(Err(e)) => match e {
|
||||||
parse::ParseError::Syntax => Err(format!("bad argument format: {}", s.quote())),
|
parse::ParseError::Syntax => Err(USimpleError::new(
|
||||||
parse::ParseError::Overflow => Err(format!(
|
1,
|
||||||
"invalid argument: {} Value too large for defined datatype",
|
format!("bad argument format: {}", s.quote()),
|
||||||
s.quote()
|
)),
|
||||||
|
parse::ParseError::Overflow => Err(USimpleError::new(
|
||||||
|
1,
|
||||||
|
format!(
|
||||||
|
"invalid argument: {} Value too large for defined datatype",
|
||||||
|
s.quote()
|
||||||
|
),
|
||||||
)),
|
)),
|
||||||
},
|
},
|
||||||
None => Ok(Box::new(vec![first, second].into_iter().chain(args))),
|
None => Ok(Box::new(vec![first, second].into_iter().chain(args))),
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Err("bad argument encoding".to_owned())
|
Err(USimpleError::new(1, "bad argument encoding".to_owned()))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Ok(Box::new(vec![first].into_iter()))
|
Ok(Box::new(vec![first].into_iter()))
|
||||||
|
@ -190,9 +196,7 @@ struct HeadOptions {
|
||||||
|
|
||||||
impl HeadOptions {
|
impl HeadOptions {
|
||||||
///Construct options from matches
|
///Construct options from matches
|
||||||
pub fn get_from(args: impl uucore::Args) -> Result<Self, String> {
|
pub fn get_from(matches: &clap::ArgMatches) -> Result<Self, String> {
|
||||||
let matches = uu_app().get_matches_from(arg_iterate(args)?);
|
|
||||||
|
|
||||||
let mut options = Self::default();
|
let mut options = Self::default();
|
||||||
|
|
||||||
options.quiet = matches.contains_id(options::QUIET_NAME);
|
options.quiet = matches.contains_id(options::QUIET_NAME);
|
||||||
|
@ -200,7 +204,7 @@ impl HeadOptions {
|
||||||
options.zeroed = matches.contains_id(options::ZERO_NAME);
|
options.zeroed = matches.contains_id(options::ZERO_NAME);
|
||||||
options.presume_input_pipe = matches.contains_id(options::PRESUME_INPUT_PIPE);
|
options.presume_input_pipe = matches.contains_id(options::PRESUME_INPUT_PIPE);
|
||||||
|
|
||||||
options.mode = Mode::from(&matches)?;
|
options.mode = Mode::from(matches)?;
|
||||||
|
|
||||||
options.files = match matches.get_many::<String>(options::FILES_NAME) {
|
options.files = match matches.get_many::<String>(options::FILES_NAME) {
|
||||||
Some(v) => v.map(|s| s.to_owned()).collect(),
|
Some(v) => v.map(|s| s.to_owned()).collect(),
|
||||||
|
@ -514,7 +518,8 @@ fn uu_head(options: &HeadOptions) -> UResult<()> {
|
||||||
|
|
||||||
#[uucore::main]
|
#[uucore::main]
|
||||||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
let args = match HeadOptions::get_from(args) {
|
let matches = uu_app().try_get_matches_from(arg_iterate(args)?)?;
|
||||||
|
let args = match HeadOptions::get_from(&matches) {
|
||||||
Ok(o) => o,
|
Ok(o) => o,
|
||||||
Err(s) => {
|
Err(s) => {
|
||||||
return Err(USimpleError::new(1, s));
|
return Err(USimpleError::new(1, s));
|
||||||
|
@ -531,8 +536,10 @@ mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
fn options(args: &str) -> Result<HeadOptions, String> {
|
fn options(args: &str) -> Result<HeadOptions, String> {
|
||||||
let combined = "head ".to_owned() + args;
|
let combined = "head ".to_owned() + args;
|
||||||
let args = combined.split_whitespace();
|
let args = combined.split_whitespace().map(OsString::from);
|
||||||
HeadOptions::get_from(args.map(OsString::from))
|
let matches = uu_app()
|
||||||
|
.get_matches_from(arg_iterate(args).map_err(|_| String::from("Arg iterate failed"))?);
|
||||||
|
HeadOptions::get_from(&matches)
|
||||||
}
|
}
|
||||||
#[test]
|
#[test]
|
||||||
fn test_args_modes() {
|
fn test_args_modes() {
|
||||||
|
@ -579,7 +586,7 @@ mod tests {
|
||||||
assert_eq!(opts.mode, Mode::FirstLines(10));
|
assert_eq!(opts.mode, Mode::FirstLines(10));
|
||||||
assert!(opts.files.is_empty());
|
assert!(opts.files.is_empty());
|
||||||
}
|
}
|
||||||
fn arg_outputs(src: &str) -> Result<String, String> {
|
fn arg_outputs(src: &str) -> Result<String, ()> {
|
||||||
let split = src.split_whitespace().map(OsString::from);
|
let split = src.split_whitespace().map(OsString::from);
|
||||||
match arg_iterate(split) {
|
match arg_iterate(split) {
|
||||||
Ok(args) => {
|
Ok(args) => {
|
||||||
|
@ -588,7 +595,7 @@ mod tests {
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
Ok(vec.join(" "))
|
Ok(vec.join(" "))
|
||||||
}
|
}
|
||||||
Err(e) => Err(e),
|
Err(_) => Err(()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -61,7 +61,7 @@ mod wsa {
|
||||||
|
|
||||||
#[uucore::main]
|
#[uucore::main]
|
||||||
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().try_get_matches_from(args)?;
|
||||||
|
|
||||||
#[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())?;
|
||||||
|
|
|
@ -128,7 +128,9 @@ struct State {
|
||||||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
let after_help = get_description();
|
let after_help = get_description();
|
||||||
|
|
||||||
let matches = uu_app().after_help(&after_help[..]).get_matches_from(args);
|
let matches = uu_app()
|
||||||
|
.after_help(&after_help[..])
|
||||||
|
.try_get_matches_from(args)?;
|
||||||
|
|
||||||
let users: Vec<String> = matches
|
let users: Vec<String> = matches
|
||||||
.get_many::<String>(options::ARG_USERS)
|
.get_many::<String>(options::ARG_USERS)
|
||||||
|
|
|
@ -171,7 +171,7 @@ static ARG_FILES: &str = "files";
|
||||||
///
|
///
|
||||||
#[uucore::main]
|
#[uucore::main]
|
||||||
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().try_get_matches_from(args)?;
|
||||||
|
|
||||||
let paths: Vec<String> = matches
|
let paths: Vec<String> = matches
|
||||||
.get_many::<String>(ARG_FILES)
|
.get_many::<String>(ARG_FILES)
|
||||||
|
|
|
@ -602,7 +602,7 @@ impl<'a> State<'a> {
|
||||||
|
|
||||||
#[uucore::main]
|
#[uucore::main]
|
||||||
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().try_get_matches_from(args)?;
|
||||||
|
|
||||||
let keys = parse_field_number_option(matches.value_of("j"))?;
|
let keys = parse_field_number_option(matches.value_of("j"))?;
|
||||||
let key1 = parse_field_number_option(matches.value_of("1"))?;
|
let key1 = parse_field_number_option(matches.value_of("1"))?;
|
||||||
|
|
|
@ -41,7 +41,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
let mut args = args.collect_ignore();
|
let mut args = args.collect_ignore();
|
||||||
let obs_signal = handle_obsolete(&mut args);
|
let obs_signal = handle_obsolete(&mut args);
|
||||||
|
|
||||||
let matches = uu_app().get_matches_from(args);
|
let matches = uu_app().try_get_matches_from(args)?;
|
||||||
|
|
||||||
let mode = if matches.contains_id(options::TABLE) {
|
let mode = if matches.contains_id(options::TABLE) {
|
||||||
Mode::Table
|
Mode::Table
|
||||||
|
|
|
@ -22,7 +22,7 @@ pub mod options {
|
||||||
|
|
||||||
#[uucore::main]
|
#[uucore::main]
|
||||||
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().try_get_matches_from(args)?;
|
||||||
|
|
||||||
let files: Vec<_> = matches
|
let files: Vec<_> = matches
|
||||||
.get_many::<OsString>(options::FILES)
|
.get_many::<OsString>(options::FILES)
|
||||||
|
|
|
@ -136,7 +136,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
long_usage,
|
long_usage,
|
||||||
backup_control::BACKUP_CONTROL_LONG_HELP
|
backup_control::BACKUP_CONTROL_LONG_HELP
|
||||||
))
|
))
|
||||||
.get_matches_from(args);
|
.try_get_matches_from(args)?;
|
||||||
|
|
||||||
/* the list of files */
|
/* the list of files */
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ static ABOUT: &str = "Print user's login name";
|
||||||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
let args = args.collect_ignore();
|
let args = args.collect_ignore();
|
||||||
|
|
||||||
let _ = uu_app().get_matches_from(args);
|
let _ = uu_app().try_get_matches_from(args)?;
|
||||||
|
|
||||||
match get_userlogin() {
|
match get_userlogin() {
|
||||||
Some(userlogin) => println!("{}", userlogin),
|
Some(userlogin) => println!("{}", userlogin),
|
||||||
|
|
|
@ -96,7 +96,9 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
// Linux-specific options, not implemented
|
// Linux-specific options, not implemented
|
||||||
// opts.optflag("Z", "context", "set SELinux security context" +
|
// opts.optflag("Z", "context", "set SELinux security context" +
|
||||||
// " of each created directory to CTX"),
|
// " of each created directory to CTX"),
|
||||||
let matches = uu_app().after_help(&after_help[..]).get_matches_from(args);
|
let matches = uu_app()
|
||||||
|
.after_help(&after_help[..])
|
||||||
|
.try_get_matches_from(args)?;
|
||||||
|
|
||||||
let dirs = matches
|
let dirs = matches
|
||||||
.get_many::<OsString>(options::DIRS)
|
.get_many::<OsString>(options::DIRS)
|
||||||
|
|
|
@ -30,7 +30,7 @@ mod options {
|
||||||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
let args = args.collect_ignore();
|
let args = args.collect_ignore();
|
||||||
|
|
||||||
let matches = uu_app().get_matches_from(args);
|
let matches = uu_app().try_get_matches_from(args)?;
|
||||||
|
|
||||||
if matches.contains_id(options::CONTEXT) {
|
if matches.contains_id(options::CONTEXT) {
|
||||||
return Err(USimpleError::new(1, "--context is not implemented"));
|
return Err(USimpleError::new(1, "--context is not implemented"));
|
||||||
|
|
|
@ -86,7 +86,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
// opts.optflag("Z", "", "set the SELinux security context to default type");
|
// opts.optflag("Z", "", "set the SELinux security context to default type");
|
||||||
// opts.optopt("", "context", "like -Z, or if CTX is specified then set the SELinux or SMACK security context to CTX");
|
// opts.optopt("", "context", "like -Z, or if CTX is specified then set the SELinux or SMACK security context to CTX");
|
||||||
|
|
||||||
let matches = uu_app().get_matches_from(args);
|
let matches = uu_app().try_get_matches_from(args)?;
|
||||||
|
|
||||||
let mode = get_mode(&matches).map_err(|e| USimpleError::new(1, e))?;
|
let mode = get_mode(&matches).map_err(|e| USimpleError::new(1, e))?;
|
||||||
|
|
||||||
|
|
|
@ -77,9 +77,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
backup_control::BACKUP_CONTROL_LONG_HELP
|
backup_control::BACKUP_CONTROL_LONG_HELP
|
||||||
);
|
);
|
||||||
let mut app = uu_app().after_help(&*help);
|
let mut app = uu_app().after_help(&*help);
|
||||||
let matches = app
|
let matches = app.try_get_matches_from_mut(args)?;
|
||||||
.try_get_matches_from_mut(args)
|
|
||||||
.unwrap_or_else(|e| e.exit());
|
|
||||||
|
|
||||||
if !matches.contains_id(OPT_TARGET_DIRECTORY)
|
if !matches.contains_id(OPT_TARGET_DIRECTORY)
|
||||||
&& matches
|
&& matches
|
||||||
|
|
|
@ -86,7 +86,7 @@ pub mod options {
|
||||||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
let args = args.collect_lossy();
|
let args = args.collect_lossy();
|
||||||
|
|
||||||
let matches = uu_app().get_matches_from(args);
|
let matches = uu_app().try_get_matches_from(args)?;
|
||||||
|
|
||||||
// A mutable settings object, initialized with the defaults.
|
// A mutable settings object, initialized with the defaults.
|
||||||
let mut settings = Settings {
|
let mut settings = Settings {
|
||||||
|
|
|
@ -21,7 +21,7 @@ use std::io::Error;
|
||||||
use std::os::unix::prelude::*;
|
use std::os::unix::prelude::*;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use uucore::display::Quotable;
|
use uucore::display::Quotable;
|
||||||
use uucore::error::{set_exit_code, UError, UResult};
|
use uucore::error::{set_exit_code, UClapError, UError, UResult};
|
||||||
use uucore::format_usage;
|
use uucore::format_usage;
|
||||||
|
|
||||||
static ABOUT: &str = "Run COMMAND ignoring hangup signals.";
|
static ABOUT: &str = "Run COMMAND ignoring hangup signals.";
|
||||||
|
@ -88,7 +88,7 @@ impl Display for NohupError {
|
||||||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
let args = args.collect_lossy();
|
let args = args.collect_lossy();
|
||||||
|
|
||||||
let matches = uu_app().get_matches_from(args);
|
let matches = uu_app().try_get_matches_from(args).with_exit_code(125)?;
|
||||||
|
|
||||||
replace_fds()?;
|
replace_fds()?;
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ const USAGE: &str = "{} [OPTIONS]...";
|
||||||
|
|
||||||
#[uucore::main]
|
#[uucore::main]
|
||||||
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().try_get_matches_from(args)?;
|
||||||
|
|
||||||
let ignore = match matches.value_of(OPT_IGNORE) {
|
let ignore = match matches.value_of(OPT_IGNORE) {
|
||||||
Some(numstr) => match numstr.trim().parse() {
|
Some(numstr) => match numstr.trim().parse() {
|
||||||
|
|
|
@ -229,7 +229,7 @@ fn concat_format_arg_and_value(args: &[String]) -> Vec<String> {
|
||||||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
let args = args.collect_ignore();
|
let args = args.collect_ignore();
|
||||||
|
|
||||||
let matches = uu_app().get_matches_from(concat_format_arg_and_value(&args));
|
let matches = uu_app().try_get_matches_from(concat_format_arg_and_value(&args))?;
|
||||||
|
|
||||||
let options = parse_options(&matches).map_err(NumfmtError::IllegalArgument)?;
|
let options = parse_options(&matches).map_err(NumfmtError::IllegalArgument)?;
|
||||||
|
|
||||||
|
|
|
@ -259,9 +259,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
|
|
||||||
let clap_opts = uu_app();
|
let clap_opts = uu_app();
|
||||||
|
|
||||||
let clap_matches = clap_opts
|
let clap_matches = clap_opts.try_get_matches_from(&args)?;
|
||||||
.clone() // Clone to reuse clap_opts to print help
|
|
||||||
.get_matches_from(args.clone());
|
|
||||||
|
|
||||||
let od_options = OdOptions::new(&clap_matches, &args)?;
|
let od_options = OdOptions::new(&clap_matches, &args)?;
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@ fn read_until<R: Read>(
|
||||||
|
|
||||||
#[uucore::main]
|
#[uucore::main]
|
||||||
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().try_get_matches_from(args)?;
|
||||||
|
|
||||||
let serial = matches.contains_id(options::SERIAL);
|
let serial = matches.contains_id(options::SERIAL);
|
||||||
let delimiters = matches.value_of(options::DELIMITER).unwrap();
|
let delimiters = matches.value_of(options::DELIMITER).unwrap();
|
||||||
|
|
|
@ -41,7 +41,7 @@ const POSIX_NAME_MAX: usize = 14;
|
||||||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
let args = args.collect_lossy();
|
let args = args.collect_lossy();
|
||||||
|
|
||||||
let matches = uu_app().get_matches_from(args);
|
let matches = uu_app().try_get_matches_from(args)?;
|
||||||
|
|
||||||
// set working mode
|
// set working mode
|
||||||
let is_posix = matches.get_many::<String>(options::POSIX).is_some();
|
let is_posix = matches.get_many::<String>(options::POSIX).is_some();
|
||||||
|
|
|
@ -53,7 +53,9 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
|
|
||||||
let after_help = get_long_usage();
|
let after_help = get_long_usage();
|
||||||
|
|
||||||
let matches = uu_app().after_help(&after_help[..]).get_matches_from(args);
|
let matches = uu_app()
|
||||||
|
.after_help(&after_help[..])
|
||||||
|
.try_get_matches_from(args)?;
|
||||||
|
|
||||||
let users: Vec<String> = matches
|
let users: Vec<String> = matches
|
||||||
.get_many::<String>(options::USER)
|
.get_many::<String>(options::USER)
|
||||||
|
|
|
@ -724,8 +724,7 @@ mod options {
|
||||||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
let args = args.collect_ignore();
|
let args = args.collect_ignore();
|
||||||
|
|
||||||
// let mut opts = Options::new();
|
let matches = uu_app().try_get_matches_from(args)?;
|
||||||
let matches = uu_app().get_matches_from(args);
|
|
||||||
|
|
||||||
let mut input_files: Vec<String> = match &matches.get_many::<String>(options::FILE) {
|
let mut input_files: Vec<String> = match &matches.get_many::<String>(options::FILE) {
|
||||||
Some(v) => v.clone().map(|v| v.to_owned()).collect(),
|
Some(v) => v.clone().map(|v| v.to_owned()).collect(),
|
||||||
|
|
|
@ -124,7 +124,7 @@ fn logical_path() -> io::Result<PathBuf> {
|
||||||
|
|
||||||
#[uucore::main]
|
#[uucore::main]
|
||||||
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().try_get_matches_from(args)?;
|
||||||
let cwd = if matches.contains_id(OPT_LOGICAL) {
|
let cwd = if matches.contains_id(OPT_LOGICAL) {
|
||||||
logical_path()
|
logical_path()
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -34,7 +34,7 @@ const ARG_FILES: &str = "files";
|
||||||
|
|
||||||
#[uucore::main]
|
#[uucore::main]
|
||||||
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().try_get_matches_from(args)?;
|
||||||
|
|
||||||
let mut no_trailing_delimiter = matches.contains_id(OPT_NO_NEWLINE);
|
let mut no_trailing_delimiter = matches.contains_id(OPT_NO_NEWLINE);
|
||||||
let use_zero = matches.contains_id(OPT_ZERO);
|
let use_zero = matches.contains_id(OPT_ZERO);
|
||||||
|
|
|
@ -81,7 +81,9 @@ fn get_long_usage() -> String {
|
||||||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
let long_usage = get_long_usage();
|
let long_usage = get_long_usage();
|
||||||
|
|
||||||
let matches = uu_app().after_help(&long_usage[..]).get_matches_from(args);
|
let matches = uu_app()
|
||||||
|
.after_help(&long_usage[..])
|
||||||
|
.try_get_matches_from(args)?;
|
||||||
|
|
||||||
let files: Vec<String> = matches
|
let files: Vec<String> = matches
|
||||||
.get_many::<String>(ARG_FILES)
|
.get_many::<String>(ARG_FILES)
|
||||||
|
|
|
@ -33,7 +33,7 @@ static ARG_DIRS: &str = "dirs";
|
||||||
|
|
||||||
#[uucore::main]
|
#[uucore::main]
|
||||||
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().try_get_matches_from(args)?;
|
||||||
|
|
||||||
let opts = Opts {
|
let opts = Opts {
|
||||||
ignore: matches.contains_id(OPT_IGNORE_FAIL_NON_EMPTY),
|
ignore: matches.contains_id(OPT_IGNORE_FAIL_NON_EMPTY),
|
||||||
|
|
|
@ -59,7 +59,7 @@ type RangeFloat = (ExtendedBigDecimal, ExtendedBigDecimal, ExtendedBigDecimal);
|
||||||
|
|
||||||
#[uucore::main]
|
#[uucore::main]
|
||||||
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().try_get_matches_from(args)?;
|
||||||
|
|
||||||
let numbers = matches
|
let numbers = matches
|
||||||
.get_many::<String>(ARG_NUMBERS)
|
.get_many::<String>(ARG_NUMBERS)
|
||||||
|
|
|
@ -268,7 +268,7 @@ pub mod options {
|
||||||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
let args = args.collect_ignore();
|
let args = args.collect_ignore();
|
||||||
|
|
||||||
let matches = uu_app().get_matches_from(args);
|
let matches = uu_app().try_get_matches_from(args)?;
|
||||||
|
|
||||||
if !matches.contains_id(options::FILE) {
|
if !matches.contains_id(options::FILE) {
|
||||||
return Err(UUsageError::new(1, "missing file operand"));
|
return Err(UUsageError::new(1, "missing file operand"));
|
||||||
|
|
|
@ -58,7 +58,7 @@ mod options {
|
||||||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
let args = args.collect_lossy();
|
let args = args.collect_lossy();
|
||||||
|
|
||||||
let matches = uu_app().get_matches_from(args);
|
let matches = uu_app().try_get_matches_from(args)?;
|
||||||
|
|
||||||
let mode = if let Some(args) = matches.get_many::<String>(options::ECHO) {
|
let mode = if let Some(args) = matches.get_many::<String>(options::ECHO) {
|
||||||
Mode::Echo(args.map(String::from).collect())
|
Mode::Echo(args.map(String::from).collect())
|
||||||
|
|
|
@ -53,7 +53,7 @@ const AFTER_HELP: &str = "\
|
||||||
|
|
||||||
#[uucore::main]
|
#[uucore::main]
|
||||||
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().try_get_matches_from(args)?;
|
||||||
match Settings::from(&matches) {
|
match Settings::from(&matches) {
|
||||||
Ok(settings) => split(&settings),
|
Ok(settings) => split(&settings),
|
||||||
Err(e) if e.requires_usage() => Err(UUsageError::new(1, format!("{}", e))),
|
Err(e) if e.requires_usage() => Err(UUsageError::new(1, format!("{}", e))),
|
||||||
|
|
|
@ -985,7 +985,9 @@ for details about the options it supports.
|
||||||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
let long_usage = get_long_usage();
|
let long_usage = get_long_usage();
|
||||||
|
|
||||||
let matches = uu_app().after_help(&long_usage[..]).get_matches_from(args);
|
let matches = uu_app()
|
||||||
|
.after_help(&long_usage[..])
|
||||||
|
.try_get_matches_from(args)?;
|
||||||
|
|
||||||
let stater = Stater::new(&matches)?;
|
let stater = Stater::new(&matches)?;
|
||||||
let exit_status = stater.exec();
|
let exit_status = stater.exec();
|
||||||
|
|
|
@ -158,7 +158,7 @@ fn get_preload_env(tmp_dir: &mut TempDir) -> io::Result<(String, PathBuf)> {
|
||||||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
let args = args.collect_ignore();
|
let args = args.collect_ignore();
|
||||||
|
|
||||||
let matches = uu_app().get_matches_from(args);
|
let matches = uu_app().try_get_matches_from(args)?;
|
||||||
|
|
||||||
let options = ProgramOptions::try_from(&matches).map_err(|e| UUsageError::new(125, e.0))?;
|
let options = ProgramOptions::try_from(&matches).map_err(|e| UUsageError::new(125, e.0))?;
|
||||||
|
|
||||||
|
|
|
@ -139,7 +139,7 @@ ioctl_write_ptr_bad!(
|
||||||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
let args = args.collect_lossy();
|
let args = args.collect_lossy();
|
||||||
|
|
||||||
let matches = uu_app().get_matches_from(args);
|
let matches = uu_app().try_get_matches_from(args)?;
|
||||||
|
|
||||||
let opts = Options::from(&matches)?;
|
let opts = Options::from(&matches)?;
|
||||||
|
|
||||||
|
|
|
@ -111,7 +111,7 @@ mod options {
|
||||||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
let args = args.collect_lossy();
|
let args = args.collect_lossy();
|
||||||
|
|
||||||
let matches = uu_app().get_matches_from(args);
|
let matches = uu_app().try_get_matches_from(args)?;
|
||||||
|
|
||||||
let files: Vec<String> = match matches.get_many::<String>(options::FILE) {
|
let files: Vec<String> = match matches.get_many::<String>(options::FILE) {
|
||||||
Some(v) => v.clone().map(|v| v.to_owned()).collect(),
|
Some(v) => v.clone().map(|v| v.to_owned()).collect(),
|
||||||
|
|
|
@ -162,7 +162,7 @@ mod platform {
|
||||||
|
|
||||||
#[uucore::main]
|
#[uucore::main]
|
||||||
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().try_get_matches_from(args)?;
|
||||||
|
|
||||||
let files: Vec<String> = matches
|
let files: Vec<String> = matches
|
||||||
.get_many::<String>(ARG_FILES)
|
.get_many::<String>(ARG_FILES)
|
||||||
|
|
|
@ -38,7 +38,7 @@ mod options {
|
||||||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
let args = args.collect_lossy();
|
let args = args.collect_lossy();
|
||||||
|
|
||||||
let matches = uu_app().get_matches_from(args);
|
let matches = uu_app().try_get_matches_from(args)?;
|
||||||
|
|
||||||
let before = matches.contains_id(options::BEFORE);
|
let before = matches.contains_id(options::BEFORE);
|
||||||
let regex = matches.contains_id(options::REGEX);
|
let regex = matches.contains_id(options::REGEX);
|
||||||
|
|
|
@ -295,7 +295,7 @@ impl Settings {
|
||||||
|
|
||||||
#[uucore::main]
|
#[uucore::main]
|
||||||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
let matches = uu_app().get_matches_from(arg_iterate(args)?);
|
let matches = uu_app().try_get_matches_from(arg_iterate(args)?)?;
|
||||||
let mut settings = Settings::from(&matches)?;
|
let mut settings = Settings::from(&matches)?;
|
||||||
|
|
||||||
// skip expensive call to fstat if PRESUME_INPUT_PIPE is selected
|
// skip expensive call to fstat if PRESUME_INPUT_PIPE is selected
|
||||||
|
|
|
@ -51,7 +51,7 @@ enum OutputErrorMode {
|
||||||
|
|
||||||
#[uucore::main]
|
#[uucore::main]
|
||||||
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().try_get_matches_from(args)?;
|
||||||
|
|
||||||
let options = Options {
|
let options = Options {
|
||||||
append: matches.contains_id(options::APPEND),
|
append: matches.contains_id(options::APPEND),
|
||||||
|
|
|
@ -19,7 +19,7 @@ use std::io::ErrorKind;
|
||||||
use std::process::{self, Child, Stdio};
|
use std::process::{self, Child, Stdio};
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
use uucore::display::Quotable;
|
use uucore::display::Quotable;
|
||||||
use uucore::error::{UResult, USimpleError, UUsageError};
|
use uucore::error::{UClapError, UResult, USimpleError, UUsageError};
|
||||||
use uucore::format_usage;
|
use uucore::format_usage;
|
||||||
use uucore::process::ChildExt;
|
use uucore::process::ChildExt;
|
||||||
use uucore::signals::{signal_by_name_or_value, signal_name_by_value};
|
use uucore::signals::{signal_by_name_or_value, signal_name_by_value};
|
||||||
|
@ -108,9 +108,7 @@ impl Config {
|
||||||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
let args = args.collect_lossy();
|
let args = args.collect_lossy();
|
||||||
|
|
||||||
let command = uu_app();
|
let matches = uu_app().try_get_matches_from(args).with_exit_code(125)?;
|
||||||
|
|
||||||
let matches = command.get_matches_from(args);
|
|
||||||
|
|
||||||
let config = Config::from(&matches)?;
|
let config = Config::from(&matches)?;
|
||||||
timeout(
|
timeout(
|
||||||
|
|
|
@ -69,7 +69,7 @@ fn dt_to_filename(tm: time::PrimitiveDateTime) -> FileTime {
|
||||||
|
|
||||||
#[uucore::main]
|
#[uucore::main]
|
||||||
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().try_get_matches_from(args)?;
|
||||||
|
|
||||||
let files = matches.get_many::<OsString>(ARG_FILES).ok_or_else(|| {
|
let files = matches.get_many::<OsString>(ARG_FILES).ok_or_else(|| {
|
||||||
USimpleError::new(
|
USimpleError::new(
|
||||||
|
|
|
@ -44,7 +44,9 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
|
|
||||||
let after_help = get_long_usage();
|
let after_help = get_long_usage();
|
||||||
|
|
||||||
let matches = uu_app().after_help(&after_help[..]).get_matches_from(args);
|
let matches = uu_app()
|
||||||
|
.after_help(&after_help[..])
|
||||||
|
.try_get_matches_from(args)?;
|
||||||
|
|
||||||
let delete_flag = matches.contains_id(options::DELETE);
|
let delete_flag = matches.contains_id(options::DELETE);
|
||||||
let complement_flag = matches.contains_id(options::COMPLEMENT);
|
let complement_flag = matches.contains_id(options::COMPLEMENT);
|
||||||
|
|
|
@ -27,7 +27,7 @@ mod options {
|
||||||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
let args = args.collect_lossy();
|
let args = args.collect_lossy();
|
||||||
|
|
||||||
let matches = uu_app().get_matches_from(args);
|
let matches = uu_app().try_get_matches_from(args)?;
|
||||||
|
|
||||||
let input = matches
|
let input = matches
|
||||||
.value_of(options::FILE)
|
.value_of(options::FILE)
|
||||||
|
|
|
@ -56,7 +56,7 @@ const HOST_OS: &str = "Redox";
|
||||||
|
|
||||||
#[uucore::main]
|
#[uucore::main]
|
||||||
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().try_get_matches_from(args)?;
|
||||||
|
|
||||||
let uname =
|
let uname =
|
||||||
PlatformInfo::new().map_err_context(|| "failed to create PlatformInfo".to_string())?;
|
PlatformInfo::new().map_err_context(|| "failed to create PlatformInfo".to_string())?;
|
||||||
|
|
|
@ -167,7 +167,7 @@ fn expand_shortcuts(args: &[String]) -> Vec<String> {
|
||||||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
let args = args.collect_ignore();
|
let args = args.collect_ignore();
|
||||||
|
|
||||||
let matches = uu_app().get_matches_from(expand_shortcuts(&args));
|
let matches = uu_app().try_get_matches_from(expand_shortcuts(&args))?;
|
||||||
|
|
||||||
unexpand(&Options::new(&matches)?).map_err_context(String::new)
|
unexpand(&Options::new(&matches)?).map_err_context(String::new)
|
||||||
}
|
}
|
||||||
|
|
|
@ -257,7 +257,9 @@ fn get_long_usage() -> String {
|
||||||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
let long_usage = get_long_usage();
|
let long_usage = get_long_usage();
|
||||||
|
|
||||||
let matches = uu_app().after_help(&long_usage[..]).get_matches_from(args);
|
let matches = uu_app()
|
||||||
|
.after_help(&long_usage[..])
|
||||||
|
.try_get_matches_from(args)?;
|
||||||
|
|
||||||
let files: Vec<String> = matches
|
let files: Vec<String> = matches
|
||||||
.get_many::<String>(ARG_FILES)
|
.get_many::<String>(ARG_FILES)
|
||||||
|
|
|
@ -22,7 +22,7 @@ static OPT_PATH: &str = "FILE";
|
||||||
|
|
||||||
#[uucore::main]
|
#[uucore::main]
|
||||||
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().try_get_matches_from(args)?;
|
||||||
|
|
||||||
let path: &Path = matches.get_one::<OsString>(OPT_PATH).unwrap().as_ref();
|
let path: &Path = matches.get_one::<OsString>(OPT_PATH).unwrap().as_ref();
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ extern "C" {
|
||||||
|
|
||||||
#[uucore::main]
|
#[uucore::main]
|
||||||
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().try_get_matches_from(args)?;
|
||||||
|
|
||||||
let (boot_time, user_count) = process_utmpx();
|
let (boot_time, user_count) = process_utmpx();
|
||||||
let uptime = get_uptime(boot_time);
|
let uptime = get_uptime(boot_time);
|
||||||
|
|
|
@ -33,7 +33,9 @@ If FILE is not specified, use {}. /var/log/wtmp as FILE is common.",
|
||||||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
let after_help = get_long_usage();
|
let after_help = get_long_usage();
|
||||||
|
|
||||||
let matches = uu_app().after_help(&after_help[..]).get_matches_from(args);
|
let matches = uu_app()
|
||||||
|
.after_help(&after_help[..])
|
||||||
|
.try_get_matches_from(args)?;
|
||||||
|
|
||||||
let files: Vec<&Path> = matches
|
let files: Vec<&Path> = matches
|
||||||
.get_many::<OsString>(ARG_FILES)
|
.get_many::<OsString>(ARG_FILES)
|
||||||
|
|
|
@ -196,7 +196,7 @@ impl Display for WcError {
|
||||||
|
|
||||||
#[uucore::main]
|
#[uucore::main]
|
||||||
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().try_get_matches_from(args)?;
|
||||||
|
|
||||||
let inputs = inputs(&matches)?;
|
let inputs = inputs(&matches)?;
|
||||||
|
|
||||||
|
|
|
@ -60,7 +60,9 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
|
|
||||||
let after_help = get_long_usage();
|
let after_help = get_long_usage();
|
||||||
|
|
||||||
let matches = uu_app().after_help(&after_help[..]).get_matches_from(args);
|
let matches = uu_app()
|
||||||
|
.after_help(&after_help[..])
|
||||||
|
.try_get_matches_from(args)?;
|
||||||
|
|
||||||
let files: Vec<String> = matches
|
let files: Vec<String> = matches
|
||||||
.get_many::<String>(options::FILE)
|
.get_many::<String>(options::FILE)
|
||||||
|
|
|
@ -21,7 +21,7 @@ static ABOUT: &str = "Print the current username.";
|
||||||
|
|
||||||
#[uucore::main]
|
#[uucore::main]
|
||||||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
uu_app().get_matches_from(args);
|
uu_app().try_get_matches_from(args)?;
|
||||||
let username = platform::get_username().map_err_context(|| "failed to get username".into())?;
|
let username = platform::get_username().map_err_context(|| "failed to get username".into())?;
|
||||||
println_verbatim(&username).map_err_context(|| "failed to print username".into())?;
|
println_verbatim(&username).map_err_context(|| "failed to print username".into())?;
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
@ -26,7 +26,7 @@ const BUF_SIZE: usize = 16 * 1024;
|
||||||
|
|
||||||
#[uucore::main]
|
#[uucore::main]
|
||||||
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().try_get_matches_from(args)?;
|
||||||
|
|
||||||
let string = if let Some(values) = matches.get_many::<String>("STRING") {
|
let string = if let Some(values) = matches.get_many::<String>("STRING") {
|
||||||
let mut result = values.fold(String::new(), |res, s| res + s + " ");
|
let mut result = values.fold(String::new(), |res, s| res + s + " ");
|
||||||
|
|
|
@ -463,7 +463,7 @@ pub fn chown_base<'a>(
|
||||||
.required(true)
|
.required(true)
|
||||||
.min_values(1),
|
.min_values(1),
|
||||||
);
|
);
|
||||||
let matches = command.get_matches_from(args);
|
let matches = command.try_get_matches_from(args)?;
|
||||||
|
|
||||||
let files: Vec<String> = matches
|
let files: Vec<String> = matches
|
||||||
.get_many::<String>(options::ARG_FILES)
|
.get_many::<String>(options::ARG_FILES)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue