change remaining usage codes of 2 to 1 for GNU compat

This commit is contained in:
Terts Diepraam
2022-09-10 20:24:24 +02:00
parent 70714bc3cd
commit 975a1d170d
74 changed files with 121 additions and 99 deletions
+1 -1
View File
@@ -16,7 +16,7 @@ static SUMMARY: &str = "Determine architecture name for current machine.";
#[uucore::main]
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())?;
println!("{}", uts.machine().trim());
+1 -1
View File
@@ -49,7 +49,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
//
// Argument parsing
//
let matches = uu_app().get_matches_from(args);
let matches = uu_app().try_get_matches_from(args)?;
// too few arguments
if !matches.contains_id(options::NAME) {
+3 -1
View File
@@ -54,7 +54,9 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
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 quiet = matches.contains_id(options::QUIET);
+2 -2
View File
@@ -15,7 +15,7 @@ use std::ffi::CString;
use std::io::Error;
use std::path::Path;
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::{entries, format_usage};
@@ -35,7 +35,7 @@ mod options {
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
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_option: &'static str = "-i";
+1 -1
View File
@@ -115,7 +115,7 @@ mod options {
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
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) {
Some(v) => v.clone().map(|v| v.to_owned()).collect(),
+1 -1
View File
@@ -134,7 +134,7 @@ fn open_file(name: &str) -> io::Result<LineReader> {
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
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 filename2 = matches.value_of(options::FILE_2).unwrap();
let mut f1 = open_file(filename1).map_err_context(|| filename1.to_string())?;
+1 -1
View File
@@ -715,7 +715,7 @@ mod tests {
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
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
let file_name = matches.value_of(options::FILE).unwrap();
+1 -1
View File
@@ -401,7 +401,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let args = args.collect_ignore();
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);
+1 -1
View File
@@ -144,7 +144,7 @@ impl<'a> From<&'a str> for Rfc3339Format {
#[uucore::main]
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) {
if !form.starts_with('+') {
+1 -1
View File
@@ -712,7 +712,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let matches = uu_app()
//.after_help(TODO: Add note about multiplier strings here.)
.get_matches_from(dashed_args);
.try_get_matches_from(dashed_args)?;
match (
matches.contains_id(options::INFILE),
+1 -1
View File
@@ -431,7 +431,7 @@ impl fmt::Display for DfError {
#[uucore::main]
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)]
{
+1 -1
View File
@@ -67,7 +67,7 @@ pub fn guess_syntax() -> OutputFmt {
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
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
.get_many::<String>(options::FILE)
+3 -1
View File
@@ -32,7 +32,9 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
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) {
"\0"
+1 -1
View File
@@ -517,7 +517,7 @@ fn build_exclude_patterns(matches: &ArgMatches) -> UResult<Vec<Pattern>> {
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
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);
+2 -2
View File
@@ -26,7 +26,7 @@ use std::iter::Iterator;
use std::os::unix::process::ExitStatusExt;
use std::process;
use uucore::display::Quotable;
use uucore::error::{UResult, USimpleError, UUsageError};
use uucore::error::{UClapError, UResult, USimpleError, UUsageError};
use uucore::format_usage;
#[cfg(unix)]
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<()> {
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 null = matches.contains_id("null");
+1 -1
View File
@@ -271,7 +271,7 @@ fn expand_shortcuts(args: &[String]) -> Vec<String> {
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
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())
}
+1 -1
View File
@@ -47,7 +47,7 @@ fn print_factors_str(
#[uucore::main]
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();
// 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());
+1 -1
View File
@@ -67,7 +67,7 @@ pub struct FmtOptions {
#[uucore::main]
#[allow(clippy::cognitive_complexity)]
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
.get_many::<String>(ARG_FILES)
+1 -1
View File
@@ -34,7 +34,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let args = args.collect_lossy();
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 spaces = matches.contains_id(options::SPACES);
+1 -1
View File
@@ -70,7 +70,7 @@ fn infallible_gid2grp(gid: &u32) -> String {
#[uucore::main]
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
.get_many::<String>(options::USERS)

Some files were not shown because too many files have changed in this diff Show More