Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

all: remove collect_{lossy,ignore} calls where possible #5649

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/uu/base32/src/base_common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@ pub fn parse_base_cmd_args(
usage: &str,
) -> UResult<Config> {
let command = base_app(about, usage);
let arg_list = args.collect_lossy();
Config::from(&command.try_get_matches_from(arg_list)?)
Config::from(&command.try_get_matches_from(args)?)
}

pub fn base_app(about: &'static str, usage: &str) -> Command {
Expand Down
2 changes: 0 additions & 2 deletions src/uu/cat/src/cat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,6 @@ mod options {

#[uucore::main]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let args = args.collect_ignore();

let matches = uu_app().try_get_matches_from(args)?;

let number_mode = if matches.get_flag(options::NUMBER_NONBLANK) {
Expand Down
2 changes: 0 additions & 2 deletions src/uu/chroot/src/chroot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ mod options {

#[uucore::main]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let args = args.collect_lossy();

let matches = uu_app().try_get_matches_from(args).with_exit_code(125)?;

let default_shell: &'static str = "/bin/sh";
Expand Down
2 changes: 0 additions & 2 deletions src/uu/cksum/src/cksum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,6 @@ mod options {

#[uucore::main]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let args = args.collect_ignore();

let matches = uu_app().try_get_matches_from(args)?;

let algo_name: &str = match matches.get_one::<String>(options::ALGORITHM) {
Expand Down
2 changes: 0 additions & 2 deletions src/uu/comm/src/comm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,6 @@ fn open_file(name: &str, line_ending: LineEnding) -> io::Result<LineReader> {

#[uucore::main]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let args = args.collect_lossy();

let matches = uu_app().try_get_matches_from(args)?;
let line_ending = LineEnding::from_zero_flag(matches.get_flag(options::ZERO_TERMINATED));
let filename1 = matches.get_one::<String>(options::FILE_1).unwrap();
Expand Down
2 changes: 0 additions & 2 deletions src/uu/csplit/src/csplit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -552,8 +552,6 @@ where

#[uucore::main]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let args = args.collect_ignore();

let matches = uu_app().try_get_matches_from(args)?;

// get the file to split
Expand Down
2 changes: 0 additions & 2 deletions src/uu/dd/src/dd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1267,8 +1267,6 @@ fn is_fifo(filename: &str) -> bool {

#[uucore::main]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let args = args.collect_ignore();

let matches = uu_app().try_get_matches_from(args)?;

let settings: Settings = Parser::new().parse(
Expand Down
2 changes: 0 additions & 2 deletions src/uu/dircolors/src/dircolors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,6 @@ fn generate_ls_colors(fmt: &OutputFmt, sep: &str) -> String {

#[uucore::main]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let args = args.collect_ignore();

let matches = uu_app().try_get_matches_from(args)?;

let files = matches
Expand Down
2 changes: 0 additions & 2 deletions src/uu/dirname/src/dirname.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ mod options {

#[uucore::main]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let args = args.collect_lossy();

let matches = uu_app().after_help(AFTER_HELP).try_get_matches_from(args)?;

let line_ending = LineEnding::from_zero_flag(matches.get_flag(options::ZERO));
Expand Down
2 changes: 0 additions & 2 deletions src/uu/du/src/du.rs
Original file line number Diff line number Diff line change
Expand Up @@ -590,8 +590,6 @@ pub fn div_ceil(a: u64, b: u64) -> u64 {
#[uucore::main]
#[allow(clippy::cognitive_complexity)]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let args = args.collect_ignore();

let matches = uu_app().try_get_matches_from(args)?;

let summarize = matches.get_flag(options::SUMMARIZE);
Expand Down
1 change: 0 additions & 1 deletion src/uu/echo/src/echo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ fn print_escaped(input: &str, mut output: impl Write) -> io::Result<ControlFlow<

#[uucore::main]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let args = args.collect_lossy();
let matches = uu_app().get_matches_from(args);

let no_newline = matches.get_flag(options::NO_NEWLINE);
Expand Down
2 changes: 0 additions & 2 deletions src/uu/expr/src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,6 @@ pub fn uu_app() -> Command {

#[uucore::main]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let args = args.collect_lossy();

// For expr utility we do not want getopts.
// The following usage should work without escaping hyphens: `expr -15 = 1 + 2 \* \( 3 - -4 \)`
let matches = uu_app().try_get_matches_from(args)?;
Expand Down
2 changes: 0 additions & 2 deletions src/uu/logname/src/logname.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ const USAGE: &str = help_usage!("logname.md");

#[uucore::main]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let args = args.collect_ignore();

let _ = uu_app().try_get_matches_from(args)?;

match get_userlogin() {
Expand Down
2 changes: 0 additions & 2 deletions src/uu/mkfifo/src/mkfifo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ mod options {

#[uucore::main]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let args = args.collect_ignore();

let matches = uu_app().try_get_matches_from(args)?;

if matches.contains_id(options::CONTEXT) {
Expand Down
1 change: 0 additions & 1 deletion src/uu/mknod/src/mknod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ fn _mknod(file_name: &str, mode: mode_t, dev: dev_t) -> i32 {

#[uucore::main]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let args = args.collect_ignore();
// Linux-specific options, not implemented
// 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");
Expand Down
6 changes: 3 additions & 3 deletions src/uu/mktemp/src/mktemp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use uucore::{format_usage, help_about, help_usage};

use std::env;
use std::error::Error;
use std::ffi::OsStr;
use std::fmt::Display;
use std::io::ErrorKind;
use std::iter;
Expand Down Expand Up @@ -308,8 +309,7 @@ impl Params {

#[uucore::main]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let args = args.collect_lossy();

let args: Vec<_> = args.collect();
let matches = match uu_app().try_get_matches_from(&args) {
Ok(m) => m,
Err(e) => {
Expand All @@ -333,7 +333,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
// If POSIXLY_CORRECT was set, template MUST be the last argument.
if matches.contains_id(ARG_TEMPLATE) {
// Template argument was provided, check if was the last one.
if args.last().unwrap() != &options.template {
if args.last().unwrap() != OsStr::new(&options.template) {
return Err(Box::new(MkTempError::TooManyTemplates));
}
}
Expand Down
1 change: 0 additions & 1 deletion src/uu/more/src/more.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ impl Options {

#[uucore::main]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let args = args.collect_lossy();
let matches = match uu_app().try_get_matches_from(args) {
Ok(m) => m,
Err(e) => return Err(e.into()),
Expand Down
2 changes: 0 additions & 2 deletions src/uu/nl/src/nl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,6 @@ pub mod options {

#[uucore::main]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let args = args.collect_lossy();

let matches = uu_app().try_get_matches_from(args)?;

let mut settings = Settings::default();
Expand Down
2 changes: 0 additions & 2 deletions src/uu/nohup/src/nohup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,6 @@ impl Display for NohupError {

#[uucore::main]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let args = args.collect_lossy();

let matches = uu_app().try_get_matches_from(args).with_exit_code(125)?;

replace_fds()?;
Expand Down
2 changes: 0 additions & 2 deletions src/uu/pathchk/src/pathchk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ const POSIX_NAME_MAX: usize = 14;

#[uucore::main]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let args = args.collect_lossy();

let matches = uu_app().try_get_matches_from(args)?;

// set working mode
Expand Down
2 changes: 0 additions & 2 deletions src/uu/pinky/src/pinky.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ fn get_long_usage() -> String {

#[uucore::main]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let args = args.collect_ignore();

let matches = uu_app()
.after_help(get_long_usage())
.try_get_matches_from(args)?;
Expand Down
1 change: 0 additions & 1 deletion src/uu/printf/src/printf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ mod options {

#[uucore::main]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let args = args.collect_ignore();
let matches = uu_app().get_matches_from(args);

let format_string = matches
Expand Down
2 changes: 0 additions & 2 deletions src/uu/ptx/src/ptx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -715,8 +715,6 @@ mod options {

#[uucore::main]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let args = args.collect_ignore();

let matches = uu_app().try_get_matches_from(args)?;

let mut input_files: Vec<String> = match &matches.get_many::<String>(options::FILE) {
Expand Down
2 changes: 0 additions & 2 deletions src/uu/shred/src/shred.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,6 @@ impl BytesWriter {

#[uucore::main]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let args = args.collect_ignore();

let matches = uu_app().try_get_matches_from(args)?;

if !matches.contains_id(options::FILE) {
Expand Down
2 changes: 0 additions & 2 deletions src/uu/shuf/src/shuf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ mod options {

#[uucore::main]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let args = args.collect_lossy();

let matches = uu_app().try_get_matches_from(args)?;

let mode = if let Some(args) = matches.get_many::<String>(options::ECHO) {
Expand Down
1 change: 0 additions & 1 deletion src/uu/sort/src/sort.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1029,7 +1029,6 @@ fn make_sort_mode_arg(mode: &'static str, short: char, help: &'static str) -> Ar
#[uucore::main]
#[allow(clippy::cognitive_complexity)]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let args = args.collect_ignore();
let mut settings = GlobalSettings::default();

let matches = match uu_app().try_get_matches_from(args) {
Expand Down
2 changes: 0 additions & 2 deletions src/uu/stdbuf/src/stdbuf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,6 @@ fn get_preload_env(tmp_dir: &TempDir) -> UResult<(String, PathBuf)> {

#[uucore::main]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let args = args.collect_ignore();

let matches = uu_app().try_get_matches_from(args)?;

let options = ProgramOptions::try_from(&matches).map_err(|e| UUsageError::new(125, e.0))?;
Expand Down
2 changes: 0 additions & 2 deletions src/uu/stty/src/stty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,6 @@ ioctl_write_ptr_bad!(

#[uucore::main]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let args = args.collect_lossy();

let matches = uu_app().try_get_matches_from(args)?;

let opts = Options::from(&matches)?;
Expand Down
2 changes: 0 additions & 2 deletions src/uu/sum/src/sum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,6 @@ mod options {

#[uucore::main]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let args = args.collect_lossy();

let matches = uu_app().try_get_matches_from(args)?;

let files: Vec<String> = match matches.get_many::<String>(options::FILE) {
Expand Down
2 changes: 0 additions & 2 deletions src/uu/tac/src/tac.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ mod options {

#[uucore::main]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let args = args.collect_lossy();

let matches = uu_app().try_get_matches_from(args)?;

let before = matches.get_flag(options::BEFORE);
Expand Down
2 changes: 0 additions & 2 deletions src/uu/timeout/src/timeout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,6 @@ impl Config {

#[uucore::main]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let args = args.collect_lossy();

let matches = uu_app().try_get_matches_from(args).with_exit_code(125)?;

let config = Config::from(&matches)?;
Expand Down
2 changes: 0 additions & 2 deletions src/uu/tr/src/tr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ mod options {

#[uucore::main]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let args = args.collect_lossy();

let matches = uu_app().after_help(AFTER_HELP).try_get_matches_from(args)?;

let delete_flag = matches.get_flag(options::DELETE);
Expand Down
2 changes: 0 additions & 2 deletions src/uu/tsort/src/tsort.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ mod options {

#[uucore::main]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let args = args.collect_lossy();

let matches = uu_app().try_get_matches_from(args)?;

let input = matches
Expand Down
2 changes: 0 additions & 2 deletions src/uu/who/src/who.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ fn get_long_usage() -> String {

#[uucore::main]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let args = args.collect_ignore();

let matches = uu_app()
.after_help(get_long_usage())
.try_get_matches_from(args)?;
Expand Down
Loading