fix clippy errors related to clap upgrade from 3.0.10 to 3.1.6

This commit is contained in:
Terts Diepraam 2022-03-17 14:40:40 +01:00
parent 59440d35c0
commit 20212be4c8
107 changed files with 532 additions and 529 deletions

View file

@ -43,7 +43,7 @@ pub fn main() {
let mut tf = File::create(Path::new(&out_dir).join("test_modules.rs")).unwrap(); let mut tf = File::create(Path::new(&out_dir).join("test_modules.rs")).unwrap();
mf.write_all( mf.write_all(
"type UtilityMap<T> = phf::Map<&'static str, (fn(T) -> i32, fn() -> App<'static>)>;\n\ "type UtilityMap<T> = phf::Map<&'static str, (fn(T) -> i32, fn() -> Command<'static>)>;\n\
\n\ \n\
fn util_map<T: uucore::Args>() -> UtilityMap<T> {\n" fn util_map<T: uucore::Args>() -> UtilityMap<T> {\n"
.as_bytes(), .as_bytes(),

View file

@ -5,7 +5,7 @@
// For the full copyright and license information, please view the LICENSE // For the full copyright and license information, please view the LICENSE
// file that was distributed with this source code. // file that was distributed with this source code.
use clap::{App, Arg}; use clap::{Arg, Command};
use clap_complete::Shell; use clap_complete::Shell;
use std::cmp; use std::cmp;
use std::ffi::OsStr; use std::ffi::OsStr;
@ -138,7 +138,7 @@ fn gen_completions<T: uucore::Args>(
.chain(util_map.keys().copied()) .chain(util_map.keys().copied())
.collect(); .collect();
let matches = App::new("completion") let matches = Command::new("completion")
.about("Prints completions to stdout") .about("Prints completions to stdout")
.arg( .arg(
Arg::new("utility") Arg::new("utility")
@ -155,7 +155,7 @@ fn gen_completions<T: uucore::Args>(
let utility = matches.value_of("utility").unwrap(); let utility = matches.value_of("utility").unwrap();
let shell = matches.value_of("shell").unwrap(); let shell = matches.value_of("shell").unwrap();
let mut app = if utility == "coreutils" { let mut command = if utility == "coreutils" {
gen_coreutils_app(util_map) gen_coreutils_app(util_map)
} else { } else {
util_map.get(utility).unwrap().1() util_map.get(utility).unwrap().1()
@ -163,15 +163,15 @@ fn gen_completions<T: uucore::Args>(
let shell: Shell = shell.parse().unwrap(); let shell: Shell = shell.parse().unwrap();
let bin_name = std::env::var("PROG_PREFIX").unwrap_or_default() + utility; let bin_name = std::env::var("PROG_PREFIX").unwrap_or_default() + utility;
clap_complete::generate(shell, &mut app, bin_name, &mut io::stdout()); clap_complete::generate(shell, &mut command, bin_name, &mut io::stdout());
io::stdout().flush().unwrap(); io::stdout().flush().unwrap();
process::exit(0); process::exit(0);
} }
fn gen_coreutils_app<T: uucore::Args>(util_map: &UtilityMap<T>) -> App<'static> { fn gen_coreutils_app<T: uucore::Args>(util_map: &UtilityMap<T>) -> Command<'static> {
let mut app = App::new("coreutils"); let mut command = Command::new("coreutils");
for (_, (_, sub_app)) in util_map { for (_, (_, sub_app)) in util_map {
app = app.subcommand(sub_app()); command = command.subcommand(sub_app());
} }
app command
} }

View file

@ -4,7 +4,7 @@
// file that was distributed with this source code. // file that was distributed with this source code.
// spell-checker:ignore tldr // spell-checker:ignore tldr
use clap::App; use clap::Command;
use std::ffi::OsString; use std::ffi::OsString;
use std::fs::File; use std::fs::File;
use std::io::Cursor; use std::io::Cursor;
@ -46,13 +46,13 @@ fn main() -> io::Result<()> {
let mut utils = utils.entries().collect::<Vec<_>>(); let mut utils = utils.entries().collect::<Vec<_>>();
utils.sort(); utils.sort();
for (&name, (_, app)) in utils { for (&name, (_, command)) in utils {
if name == "[" { if name == "[" {
continue; continue;
} }
let p = format!("docs/src/utils/{}.md", name); let p = format!("docs/src/utils/{}.md", name);
if let Ok(f) = File::create(&p) { if let Ok(f) = File::create(&p) {
write_markdown(f, &mut app(), name, &mut tldr_zip)?; write_markdown(f, &mut command(), name, &mut tldr_zip)?;
println!("Wrote to '{}'", p); println!("Wrote to '{}'", p);
} else { } else {
println!("Error writing to {}", p); println!("Error writing to {}", p);
@ -64,29 +64,29 @@ fn main() -> io::Result<()> {
fn write_markdown( fn write_markdown(
mut w: impl Write, mut w: impl Write,
app: &mut App, command: &mut Command,
name: &str, name: &str,
tldr_zip: &mut zip::ZipArchive<impl Read + Seek>, tldr_zip: &mut zip::ZipArchive<impl Read + Seek>,
) -> io::Result<()> { ) -> io::Result<()> {
write!(w, "# {}\n\n", name)?; write!(w, "# {}\n\n", name)?;
write_version(&mut w, app)?; write_version(&mut w, command)?;
write_usage(&mut w, app, name)?; write_usage(&mut w, command, name)?;
write_description(&mut w, app)?; write_description(&mut w, command)?;
write_options(&mut w, app)?; write_options(&mut w, command)?;
write_examples(&mut w, name, tldr_zip) write_examples(&mut w, name, tldr_zip)
} }
fn write_version(w: &mut impl Write, app: &App) -> io::Result<()> { fn write_version(w: &mut impl Write, command: &Command) -> io::Result<()> {
writeln!( writeln!(
w, w,
"<div class=\"version\">version: {}</div>", "<div class=\"version\">version: {}</div>",
app.render_version().split_once(' ').unwrap().1 command.render_version().split_once(' ').unwrap().1
) )
} }
fn write_usage(w: &mut impl Write, app: &mut App, name: &str) -> io::Result<()> { fn write_usage(w: &mut impl Write, command: &mut Command, name: &str) -> io::Result<()> {
writeln!(w, "\n```")?; writeln!(w, "\n```")?;
let mut usage: String = app let mut usage: String = command
.render_usage() .render_usage()
.lines() .lines()
.skip(1) .skip(1)
@ -99,8 +99,8 @@ fn write_usage(w: &mut impl Write, app: &mut App, name: &str) -> io::Result<()>
writeln!(w, "```") writeln!(w, "```")
} }
fn write_description(w: &mut impl Write, app: &App) -> io::Result<()> { fn write_description(w: &mut impl Write, command: &Command) -> io::Result<()> {
if let Some(about) = app.get_long_about().or_else(|| app.get_about()) { if let Some(about) = command.get_long_about().or_else(|| command.get_about()) {
writeln!(w, "{}", about) writeln!(w, "{}", about)
} else { } else {
Ok(()) Ok(())
@ -152,10 +152,10 @@ fn get_zip_content(archive: &mut ZipArchive<impl Read + Seek>, name: &str) -> Op
Some(s) Some(s)
} }
fn write_options(w: &mut impl Write, app: &App) -> io::Result<()> { fn write_options(w: &mut impl Write, command: &Command) -> io::Result<()> {
writeln!(w, "<h2>Options</h2>")?; writeln!(w, "<h2>Options</h2>")?;
write!(w, "<dl>")?; write!(w, "<dl>")?;
for arg in app.get_arguments() { for arg in command.get_arguments() {
write!(w, "<dt>")?; write!(w, "<dt>")?;
let mut first = true; let mut first = true;
for l in arg.get_long_and_visible_aliases().unwrap_or_default() { for l in arg.get_long_and_visible_aliases().unwrap_or_default() {

View file

@ -8,7 +8,7 @@
use platform_info::*; use platform_info::*;
use clap::{crate_version, App, AppSettings}; use clap::{crate_version, Command};
use uucore::error::{FromIo, UResult}; use uucore::error::{FromIo, UResult};
static ABOUT: &str = "Display machine architecture"; static ABOUT: &str = "Display machine architecture";
@ -23,10 +23,10 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
Ok(()) Ok(())
} }
pub fn uu_app<'a>() -> App<'a> { pub fn uu_app<'a>() -> Command<'a> {
App::new(uucore::util_name()) Command::new(uucore::util_name())
.version(crate_version!()) .version(crate_version!())
.about(ABOUT) .about(ABOUT)
.after_help(SUMMARY) .after_help(SUMMARY)
.setting(AppSettings::InferLongArgs) .infer_long_args(true)
} }

View file

@ -7,7 +7,7 @@
use std::io::{stdin, Read}; use std::io::{stdin, Read};
use clap::App; use clap::Command;
use uucore::{encoding::Format, error::UResult}; use uucore::{encoding::Format, error::UResult};
pub mod base_common; pub mod base_common;
@ -44,6 +44,6 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
) )
} }
pub fn uu_app<'a>() -> App<'a> { pub fn uu_app<'a>() -> Command<'a> {
base_common::base_app(ABOUT, USAGE) base_common::base_app(ABOUT, USAGE)
} }

View file

@ -18,7 +18,7 @@ use std::fs::File;
use std::io::{BufReader, Stdin}; use std::io::{BufReader, Stdin};
use std::path::Path; use std::path::Path;
use clap::{crate_version, App, AppSettings, Arg}; use clap::{crate_version, Arg, Command};
pub static BASE_CMD_PARSE_ERROR: i32 = 1; pub static BASE_CMD_PARSE_ERROR: i32 = 1;
@ -86,19 +86,19 @@ impl Config {
} }
pub fn parse_base_cmd_args(args: impl uucore::Args, about: &str, usage: &str) -> UResult<Config> { pub fn parse_base_cmd_args(args: impl uucore::Args, about: &str, usage: &str) -> UResult<Config> {
let app = base_app(about, usage); let command = base_app(about, usage);
let arg_list = args let arg_list = args
.collect_str(InvalidEncodingHandling::ConvertLossy) .collect_str(InvalidEncodingHandling::ConvertLossy)
.accept_any(); .accept_any();
Config::from(&app.get_matches_from(arg_list)) Config::from(&command.get_matches_from(arg_list))
} }
pub fn base_app<'a>(about: &'a str, usage: &'a str) -> App<'a> { pub fn base_app<'a>(about: &'a str, usage: &'a str) -> Command<'a> {
App::new(uucore::util_name()) Command::new(uucore::util_name())
.version(crate_version!()) .version(crate_version!())
.about(about) .about(about)
.override_usage(format_usage(usage)) .override_usage(format_usage(usage))
.setting(AppSettings::InferLongArgs) .infer_long_args(true)
// Format arguments. // Format arguments.
.arg( .arg(
Arg::new(options::DECODE) Arg::new(options::DECODE)

View file

@ -7,7 +7,7 @@
// spell-checker:ignore (ToDO) fullname // spell-checker:ignore (ToDO) fullname
use clap::{crate_version, App, AppSettings, Arg}; use clap::{crate_version, Arg, Command};
use std::path::{is_separator, PathBuf}; use std::path::{is_separator, PathBuf};
use uucore::display::Quotable; use uucore::display::Quotable;
use uucore::error::{UResult, UUsageError}; use uucore::error::{UResult, UUsageError};
@ -87,12 +87,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
Ok(()) Ok(())
} }
pub fn uu_app<'a>() -> App<'a> { pub fn uu_app<'a>() -> Command<'a> {
App::new(uucore::util_name()) Command::new(uucore::util_name())
.version(crate_version!()) .version(crate_version!())
.about(SUMMARY) .about(SUMMARY)
.override_usage(format_usage(USAGE)) .override_usage(format_usage(USAGE))
.setting(AppSettings::InferLongArgs) .infer_long_args(true)
.arg( .arg(
Arg::new(options::MULTIPLE) Arg::new(options::MULTIPLE)
.short('a') .short('a')

View file

@ -8,7 +8,7 @@
//spell-checker:ignore (args) lsbf msbf //spell-checker:ignore (args) lsbf msbf
use clap::{App, Arg}; use clap::{Arg, Command};
use uu_base32::base_common::{self, Config, BASE_CMD_PARSE_ERROR}; use uu_base32::base_common::{self, Config, BASE_CMD_PARSE_ERROR};
use uucore::{ use uucore::{
@ -40,12 +40,12 @@ const ENCODINGS: &[(&str, Format)] = &[
const USAGE: &str = "{} [OPTION]... [FILE]"; const USAGE: &str = "{} [OPTION]... [FILE]";
pub fn uu_app<'a>() -> App<'a> { pub fn uu_app<'a>() -> Command<'a> {
let mut app = base_common::base_app(ABOUT, USAGE); let mut command = base_common::base_app(ABOUT, USAGE);
for encoding in ENCODINGS { for encoding in ENCODINGS {
app = app.arg(Arg::new(encoding.0).long(encoding.0)); command = command.arg(Arg::new(encoding.0).long(encoding.0));
} }
app command
} }
fn parse_cmd_args(args: impl uucore::Args) -> UResult<(Config, Format)> { fn parse_cmd_args(args: impl uucore::Args) -> UResult<(Config, Format)> {

View file

@ -14,7 +14,7 @@
extern crate unix_socket; extern crate unix_socket;
// last synced with: cat (GNU coreutils) 8.13 // last synced with: cat (GNU coreutils) 8.13
use clap::{crate_version, App, AppSettings, Arg}; use clap::{crate_version, Arg, Command};
use std::fs::{metadata, File}; use std::fs::{metadata, File};
use std::io::{self, Read, Write}; use std::io::{self, Read, Write};
use thiserror::Error; use thiserror::Error;
@ -239,13 +239,13 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
cat_files(&files, &options) cat_files(&files, &options)
} }
pub fn uu_app<'a>() -> App<'a> { pub fn uu_app<'a>() -> Command<'a> {
App::new(uucore::util_name()) Command::new(uucore::util_name())
.name(NAME) .name(NAME)
.version(crate_version!()) .version(crate_version!())
.override_usage(format_usage(USAGE)) .override_usage(format_usage(USAGE))
.about(SUMMARY) .about(SUMMARY)
.setting(AppSettings::InferLongArgs) .infer_long_args(true)
.arg( .arg(
Arg::new(options::FILE) Arg::new(options::FILE)
.hide(true) .hide(true)

View file

@ -6,7 +6,7 @@ use uucore::error::{UResult, USimpleError, UUsageError};
use uucore::format_usage; use uucore::format_usage;
use uucore::{display::Quotable, show_error, show_warning}; use uucore::{display::Quotable, show_error, show_warning};
use clap::{App, AppSettings, Arg}; use clap::{Arg, Command};
use selinux::{OpaqueSecurityContext, SecurityContext}; use selinux::{OpaqueSecurityContext, SecurityContext};
use std::borrow::Cow; use std::borrow::Cow;
@ -65,7 +65,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
Ok(r) => r, Ok(r) => r,
Err(r) => { Err(r) => {
if let Error::CommandLine(r) = &r { if let Error::CommandLine(r) = &r {
match r.kind { match r.kind() {
clap::ErrorKind::DisplayHelp | clap::ErrorKind::DisplayVersion => { clap::ErrorKind::DisplayHelp | clap::ErrorKind::DisplayVersion => {
println!("{}", r); println!("{}", r);
return Ok(()); return Ok(());
@ -154,12 +154,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
Err(libc::EXIT_FAILURE.into()) Err(libc::EXIT_FAILURE.into())
} }
pub fn uu_app<'a>() -> App<'a> { pub fn uu_app<'a>() -> Command<'a> {
App::new(uucore::util_name()) Command::new(uucore::util_name())
.version(VERSION) .version(VERSION)
.about(ABOUT) .about(ABOUT)
.override_usage(format_usage(USAGE)) .override_usage(format_usage(USAGE))
.setting(AppSettings::InferLongArgs) .infer_long_args(true)
.arg( .arg(
Arg::new(options::dereference::DEREFERENCE) Arg::new(options::dereference::DEREFERENCE)
.long(options::dereference::DEREFERENCE) .long(options::dereference::DEREFERENCE)
@ -303,7 +303,7 @@ struct Options {
files: Vec<PathBuf>, files: Vec<PathBuf>,
} }
fn parse_command_line(config: clap::App, args: impl uucore::Args) -> Result<Options> { fn parse_command_line(config: clap::Command, args: impl uucore::Args) -> Result<Options> {
let matches = config.try_get_matches_from(args)?; let matches = config.try_get_matches_from(args)?;
let verbose = matches.is_present(options::VERBOSE); let verbose = matches.is_present(options::VERBOSE);

View file

@ -13,7 +13,7 @@ use uucore::error::{FromIo, UResult, USimpleError};
use uucore::format_usage; use uucore::format_usage;
use uucore::perms::{chown_base, options, IfFrom}; use uucore::perms::{chown_base, options, IfFrom};
use clap::{App, AppSettings, Arg, ArgMatches}; use clap::{Arg, ArgMatches, Command};
use std::fs; use std::fs;
use std::os::unix::fs::MetadataExt; use std::os::unix::fs::MetadataExt;
@ -54,12 +54,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
chown_base(uu_app(), args, options::ARG_GROUP, parse_gid_and_uid, true) chown_base(uu_app(), args, options::ARG_GROUP, parse_gid_and_uid, true)
} }
pub fn uu_app<'a>() -> App<'a> { pub fn uu_app<'a>() -> Command<'a> {
App::new(uucore::util_name()) Command::new(uucore::util_name())
.version(VERSION) .version(VERSION)
.about(ABOUT) .about(ABOUT)
.override_usage(format_usage(USAGE)) .override_usage(format_usage(USAGE))
.setting(AppSettings::InferLongArgs) .infer_long_args(true)
.arg( .arg(
Arg::new(options::verbosity::CHANGES) Arg::new(options::verbosity::CHANGES)
.short('c') .short('c')

View file

@ -7,7 +7,7 @@
// spell-checker:ignore (ToDO) Chmoder cmode fmode fperm fref ugoa RFILE RFILE's // spell-checker:ignore (ToDO) Chmoder cmode fmode fperm fref ugoa RFILE RFILE's
use clap::{crate_version, App, AppSettings, Arg}; use clap::{crate_version, Arg, Command};
use std::fs; use std::fs;
use std::os::unix::fs::{MetadataExt, PermissionsExt}; use std::os::unix::fs::{MetadataExt, PermissionsExt};
use std::path::Path; use std::path::Path;
@ -112,12 +112,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
chmoder.chmod(&files) chmoder.chmod(&files)
} }
pub fn uu_app<'a>() -> App<'a> { pub fn uu_app<'a>() -> Command<'a> {
App::new(uucore::util_name()) Command::new(uucore::util_name())
.version(crate_version!()) .version(crate_version!())
.about(ABOUT) .about(ABOUT)
.override_usage(format_usage(USAGE)) .override_usage(format_usage(USAGE))
.setting(AppSettings::InferLongArgs) .infer_long_args(true)
.arg( .arg(
Arg::new(options::CHANGES) Arg::new(options::CHANGES)
.long(options::CHANGES) .long(options::CHANGES)

View file

@ -14,7 +14,7 @@ use uucore::perms::{chown_base, options, IfFrom};
use uucore::error::{FromIo, UResult, USimpleError}; use uucore::error::{FromIo, UResult, USimpleError};
use clap::{crate_version, App, AppSettings, Arg, ArgMatches}; use clap::{crate_version, Arg, ArgMatches, Command};
use std::fs; use std::fs;
use std::os::unix::fs::MetadataExt; use std::os::unix::fs::MetadataExt;
@ -63,12 +63,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
) )
} }
pub fn uu_app<'a>() -> App<'a> { pub fn uu_app<'a>() -> Command<'a> {
App::new(uucore::util_name()) Command::new(uucore::util_name())
.version(crate_version!()) .version(crate_version!())
.about(ABOUT) .about(ABOUT)
.override_usage(format_usage(USAGE)) .override_usage(format_usage(USAGE))
.setting(AppSettings::InferLongArgs) .infer_long_args(true)
.arg( .arg(
Arg::new(options::verbosity::CHANGES) Arg::new(options::verbosity::CHANGES)
.short('c') .short('c')

View file

@ -10,11 +10,11 @@
mod error; mod error;
use crate::error::ChrootError; use crate::error::ChrootError;
use clap::{crate_version, App, AppSettings, Arg}; use clap::{crate_version, Arg, Command};
use std::ffi::CString; use std::ffi::CString;
use std::io::Error; use std::io::Error;
use std::path::Path; use std::path::Path;
use std::process::Command; use std::process;
use uucore::error::{set_exit_code, UResult}; use uucore::error::{set_exit_code, UResult};
use uucore::libc::{self, chroot, setgid, setgroups, setuid}; use uucore::libc::{self, chroot, setgid, setgroups, setuid};
use uucore::{entries, format_usage, InvalidEncodingHandling}; use uucore::{entries, format_usage, InvalidEncodingHandling};
@ -77,7 +77,10 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
// NOTE: Tests can only trigger code beyond this point if they're invoked with root permissions // NOTE: Tests can only trigger code beyond this point if they're invoked with root permissions
set_context(newroot, &matches)?; set_context(newroot, &matches)?;
let pstatus = match Command::new(chroot_command).args(chroot_args).status() { let pstatus = match process::Command::new(chroot_command)
.args(chroot_args)
.status()
{
Ok(status) => status, Ok(status) => status,
Err(e) => return Err(ChrootError::CommandFailed(command[0].to_string(), e).into()), Err(e) => return Err(ChrootError::CommandFailed(command[0].to_string(), e).into()),
}; };
@ -91,12 +94,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
Ok(()) Ok(())
} }
pub fn uu_app<'a>() -> App<'a> { pub fn uu_app<'a>() -> Command<'a> {
App::new(uucore::util_name()) Command::new(uucore::util_name())
.version(crate_version!()) .version(crate_version!())
.about(ABOUT) .about(ABOUT)
.override_usage(format_usage(USAGE)) .override_usage(format_usage(USAGE))
.setting(AppSettings::InferLongArgs) .infer_long_args(true)
.arg( .arg(
Arg::new(options::NEWROOT) Arg::new(options::NEWROOT)
.hide(true) .hide(true)

View file

@ -6,7 +6,7 @@
// file that was distributed with this source code. // file that was distributed with this source code.
// spell-checker:ignore (ToDO) fname // spell-checker:ignore (ToDO) fname
use clap::{crate_version, App, AppSettings, Arg}; use clap::{crate_version, Arg, Command};
use std::fs::File; use std::fs::File;
use std::io::{self, stdin, BufReader, Read}; use std::io::{self, stdin, BufReader, Read};
use std::path::Path; use std::path::Path;
@ -140,13 +140,13 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
Ok(()) Ok(())
} }
pub fn uu_app<'a>() -> App<'a> { pub fn uu_app<'a>() -> Command<'a> {
App::new(uucore::util_name()) Command::new(uucore::util_name())
.name(NAME) .name(NAME)
.version(crate_version!()) .version(crate_version!())
.about(SUMMARY) .about(SUMMARY)
.override_usage(format_usage(USAGE)) .override_usage(format_usage(USAGE))
.setting(AppSettings::InferLongArgs) .infer_long_args(true)
.arg( .arg(
Arg::new(options::FILE) Arg::new(options::FILE)
.hide(true) .hide(true)

View file

@ -15,7 +15,7 @@ use uucore::error::FromIo;
use uucore::error::UResult; use uucore::error::UResult;
use uucore::{format_usage, InvalidEncodingHandling}; use uucore::{format_usage, InvalidEncodingHandling};
use clap::{crate_version, App, AppSettings, Arg, ArgMatches}; use clap::{crate_version, Arg, ArgMatches, Command};
static ABOUT: &str = "compare two sorted files line by line"; static ABOUT: &str = "compare two sorted files line by line";
static LONG_HELP: &str = ""; static LONG_HELP: &str = "";
@ -143,13 +143,13 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
Ok(()) Ok(())
} }
pub fn uu_app<'a>() -> App<'a> { pub fn uu_app<'a>() -> Command<'a> {
App::new(uucore::util_name()) Command::new(uucore::util_name())
.version(crate_version!()) .version(crate_version!())
.about(ABOUT) .about(ABOUT)
.after_help(LONG_HELP) .after_help(LONG_HELP)
.override_usage(format_usage(USAGE)) .override_usage(format_usage(USAGE))
.setting(AppSettings::InferLongArgs) .infer_long_args(true)
.arg( .arg(
Arg::new(options::COLUMN_1) Arg::new(options::COLUMN_1)
.short('1') .short('1')

View file

@ -28,7 +28,7 @@ use winapi::um::fileapi::GetFileInformationByHandle;
use std::borrow::Cow; use std::borrow::Cow;
use clap::{crate_version, App, AppSettings, Arg, ArgMatches}; use clap::{crate_version, Arg, ArgMatches, Command};
use filetime::FileTime; use filetime::FileTime;
#[cfg(unix)] #[cfg(unix)]
use libc::mkfifo; use libc::mkfifo;
@ -296,7 +296,7 @@ static DEFAULT_ATTRIBUTES: &[Attribute] = &[
Attribute::Timestamps, Attribute::Timestamps,
]; ];
pub fn uu_app<'a>() -> App<'a> { pub fn uu_app<'a>() -> Command<'a> {
const MODE_ARGS: &[&str] = &[ const MODE_ARGS: &[&str] = &[
options::LINK, options::LINK,
options::REFLINK, options::REFLINK,
@ -304,11 +304,11 @@ pub fn uu_app<'a>() -> App<'a> {
options::ATTRIBUTES_ONLY, options::ATTRIBUTES_ONLY,
options::COPY_CONTENTS, options::COPY_CONTENTS,
]; ];
App::new(uucore::util_name()) Command::new(uucore::util_name())
.version(crate_version!()) .version(crate_version!())
.about(ABOUT) .about(ABOUT)
.override_usage(format_usage(USAGE)) .override_usage(format_usage(USAGE))
.setting(AppSettings::InferLongArgs) .infer_long_args(true)
.arg(Arg::new(options::TARGET_DIRECTORY) .arg(Arg::new(options::TARGET_DIRECTORY)
.short('t') .short('t')
.conflicts_with(options::NO_TARGET_DIRECTORY) .conflicts_with(options::NO_TARGET_DIRECTORY)
@ -389,7 +389,7 @@ pub fn uu_app<'a>() -> App<'a> {
.long(options::PRESERVE) .long(options::PRESERVE)
.takes_value(true) .takes_value(true)
.multiple_occurrences(true) .multiple_occurrences(true)
.use_delimiter(true) .use_value_delimiter(true)
.possible_values(PRESERVABLE_ATTRIBUTES) .possible_values(PRESERVABLE_ATTRIBUTES)
.min_values(0) .min_values(0)
.value_name("ATTR_LIST") .value_name("ATTR_LIST")

View file

@ -12,7 +12,7 @@ use std::{
io::{BufRead, BufWriter, Write}, io::{BufRead, BufWriter, Write},
}; };
use clap::{crate_version, App, AppSettings, Arg, ArgMatches}; use clap::{crate_version, Arg, ArgMatches, Command};
use regex::Regex; use regex::Regex;
use uucore::display::Quotable; use uucore::display::Quotable;
use uucore::error::{FromIo, UResult}; use uucore::error::{FromIo, UResult};
@ -746,12 +746,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
} }
} }
pub fn uu_app<'a>() -> App<'a> { pub fn uu_app<'a>() -> Command<'a> {
App::new(uucore::util_name()) Command::new(uucore::util_name())
.version(crate_version!()) .version(crate_version!())
.about(SUMMARY) .about(SUMMARY)
.override_usage(format_usage(USAGE)) .override_usage(format_usage(USAGE))
.setting(AppSettings::InferLongArgs) .infer_long_args(true)
.arg( .arg(
Arg::new(options::SUFFIX_FORMAT) Arg::new(options::SUFFIX_FORMAT)
.short('b') .short('b')

View file

@ -11,7 +11,7 @@
extern crate uucore; extern crate uucore;
use bstr::io::BufReadExt; use bstr::io::BufReadExt;
use clap::{crate_version, App, AppSettings, Arg}; use clap::{crate_version, Arg, Command};
use std::fs::File; use std::fs::File;
use std::io::{stdin, stdout, BufReader, BufWriter, Read, Write}; use std::io::{stdin, stdout, BufReader, BufWriter, Read, Write};
use std::path::Path; use std::path::Path;
@ -533,14 +533,14 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
} }
} }
pub fn uu_app<'a>() -> App<'a> { pub fn uu_app<'a>() -> Command<'a> {
App::new(uucore::util_name()) Command::new(uucore::util_name())
.name(NAME) .name(NAME)
.version(crate_version!()) .version(crate_version!())
.override_usage(format_usage(USAGE)) .override_usage(format_usage(USAGE))
.about(SUMMARY) .about(SUMMARY)
.after_help(LONG_HELP) .after_help(LONG_HELP)
.setting(AppSettings::InferLongArgs) .infer_long_args(true)
.arg( .arg(
Arg::new(options::BYTES) Arg::new(options::BYTES)
.short('b') .short('b')

View file

@ -11,7 +11,7 @@
use chrono::{DateTime, FixedOffset, Local, Offset, Utc}; use chrono::{DateTime, FixedOffset, Local, Offset, Utc};
#[cfg(windows)] #[cfg(windows)]
use chrono::{Datelike, Timelike}; use chrono::{Datelike, Timelike};
use clap::{crate_version, App, AppSettings, Arg}; use clap::{crate_version, Arg, Command};
#[cfg(all(unix, not(target_os = "macos"), not(target_os = "redox")))] #[cfg(all(unix, not(target_os = "macos"), not(target_os = "redox")))]
use libc::{clock_settime, timespec, CLOCK_REALTIME}; use libc::{clock_settime, timespec, CLOCK_REALTIME};
use std::fs::File; use std::fs::File;
@ -254,12 +254,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
Ok(()) Ok(())
} }
pub fn uu_app<'a>() -> App<'a> { pub fn uu_app<'a>() -> Command<'a> {
App::new(uucore::util_name()) Command::new(uucore::util_name())
.version(crate_version!()) .version(crate_version!())
.about(ABOUT) .about(ABOUT)
.override_usage(format_usage(USAGE)) .override_usage(format_usage(USAGE))
.setting(AppSettings::InferLongArgs) .infer_long_args(true)
.arg( .arg(
Arg::new(OPT_DATE) Arg::new(OPT_DATE)
.short('d') .short('d')

View file

@ -34,7 +34,7 @@ use std::sync::mpsc;
use std::thread; use std::thread;
use std::time; use std::time;
use clap::{crate_version, App, AppSettings, Arg, ArgMatches}; use clap::{crate_version, Arg, ArgMatches, Command};
use gcd::Gcd; use gcd::Gcd;
use uucore::display::Quotable; use uucore::display::Quotable;
use uucore::error::{FromIo, UResult}; use uucore::error::{FromIo, UResult};
@ -730,11 +730,11 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
} }
} }
pub fn uu_app<'a>() -> App<'a> { pub fn uu_app<'a>() -> Command<'a> {
App::new(uucore::util_name()) Command::new(uucore::util_name())
.version(crate_version!()) .version(crate_version!())
.about(ABOUT) .about(ABOUT)
.setting(AppSettings::InferLongArgs) .infer_long_args(true)
.arg( .arg(
Arg::new(options::INFILE) Arg::new(options::INFILE)
.long(options::INFILE) .long(options::INFILE)
@ -846,8 +846,8 @@ Printing performance stats is also triggered by the INFO signal (where supported
.long(options::CONV) .long(options::CONV)
.takes_value(true) .takes_value(true)
.multiple_occurrences(true) .multiple_occurrences(true)
.use_delimiter(true) .use_value_delimiter(true)
.require_delimiter(true) .require_value_delimiter(true)
.multiple_values(true) .multiple_values(true)
.require_equals(true) .require_equals(true)
.value_name("CONV") .value_name("CONV")
@ -887,8 +887,8 @@ Conversion Flags:
.long(options::IFLAG) .long(options::IFLAG)
.takes_value(true) .takes_value(true)
.multiple_occurrences(true) .multiple_occurrences(true)
.use_delimiter(true) .use_value_delimiter(true)
.require_delimiter(true) .require_value_delimiter(true)
.multiple_values(true) .multiple_values(true)
.require_equals(true) .require_equals(true)
.value_name("FLAG") .value_name("FLAG")
@ -917,8 +917,8 @@ General-Flags
.long(options::OFLAG) .long(options::OFLAG)
.takes_value(true) .takes_value(true)
.multiple_occurrences(true) .multiple_occurrences(true)
.use_delimiter(true) .use_value_delimiter(true)
.require_delimiter(true) .require_value_delimiter(true)
.multiple_values(true) .multiple_values(true)
.require_equals(true) .require_equals(true)
.value_name("FLAG") .value_name("FLAG")

View file

@ -15,7 +15,7 @@ use uucore::error::{UResult, USimpleError};
use uucore::format_usage; use uucore::format_usage;
use uucore::fsext::{read_fs_list, MountInfo}; use uucore::fsext::{read_fs_list, MountInfo};
use clap::{crate_version, App, AppSettings, Arg, ArgMatches}; use clap::{crate_version, Arg, ArgMatches, Command};
use std::fmt; use std::fmt;
use std::path::Path; use std::path::Path;
@ -316,12 +316,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
Ok(()) Ok(())
} }
pub fn uu_app<'a>() -> App<'a> { pub fn uu_app<'a>() -> Command<'a> {
App::new(uucore::util_name()) Command::new(uucore::util_name())
.version(crate_version!()) .version(crate_version!())
.about(ABOUT) .about(ABOUT)
.override_usage(format_usage(USAGE)) .override_usage(format_usage(USAGE))
.setting(AppSettings::InferLongArgs) .infer_long_args(true)
.arg( .arg(
Arg::new(OPT_ALL) Arg::new(OPT_ALL)
.short('a') .short('a')
@ -385,7 +385,7 @@ pub fn uu_app<'a>() -> App<'a> {
Arg::new(OPT_OUTPUT) Arg::new(OPT_OUTPUT)
.long("output") .long("output")
.takes_value(true) .takes_value(true)
.use_delimiter(true) .use_value_delimiter(true)
.possible_values(OUTPUT_FIELD_LIST) .possible_values(OUTPUT_FIELD_LIST)
.default_missing_values(&OUTPUT_FIELD_LIST) .default_missing_values(&OUTPUT_FIELD_LIST)
.default_values(&["source", "size", "used", "avail", "pcent", "target"]) .default_values(&["source", "size", "used", "avail", "pcent", "target"])
@ -428,7 +428,7 @@ pub fn uu_app<'a>() -> App<'a> {
.long("exclude-type") .long("exclude-type")
.allow_invalid_utf8(true) .allow_invalid_utf8(true)
.takes_value(true) .takes_value(true)
.use_delimiter(true) .use_value_delimiter(true)
.multiple_occurrences(true) .multiple_occurrences(true)
.help("limit listing to file systems not of type TYPE"), .help("limit listing to file systems not of type TYPE"),
) )

View file

@ -13,7 +13,7 @@ use std::env;
use std::fs::File; use std::fs::File;
use std::io::{BufRead, BufReader}; use std::io::{BufRead, BufReader};
use clap::{crate_version, App, AppSettings, Arg}; use clap::{crate_version, Arg, Command};
use uucore::display::Quotable; use uucore::display::Quotable;
use uucore::error::{UResult, USimpleError, UUsageError}; use uucore::error::{UResult, USimpleError, UUsageError};
@ -154,13 +154,13 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
} }
} }
pub fn uu_app<'a>() -> App<'a> { pub fn uu_app<'a>() -> Command<'a> {
App::new(uucore::util_name()) Command::new(uucore::util_name())
.version(crate_version!()) .version(crate_version!())
.about(SUMMARY) .about(SUMMARY)
.after_help(LONG_HELP) .after_help(LONG_HELP)
.override_usage(format_usage(USAGE)) .override_usage(format_usage(USAGE))
.setting(AppSettings::InferLongArgs) .infer_long_args(true)
.arg( .arg(
Arg::new(options::BOURNE_SHELL) Arg::new(options::BOURNE_SHELL)
.long("sh") .long("sh")

View file

@ -5,7 +5,7 @@
// For the full copyright and license information, please view the LICENSE // For the full copyright and license information, please view the LICENSE
// file that was distributed with this source code. // file that was distributed with this source code.
use clap::{crate_version, App, AppSettings, Arg}; use clap::{crate_version, Arg, Command};
use std::path::Path; use std::path::Path;
use uucore::display::print_verbatim; use uucore::display::print_verbatim;
use uucore::error::{UResult, UUsageError}; use uucore::error::{UResult, UUsageError};
@ -76,12 +76,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
Ok(()) Ok(())
} }
pub fn uu_app<'a>() -> App<'a> { pub fn uu_app<'a>() -> Command<'a> {
App::new(uucore::util_name()) Command::new(uucore::util_name())
.about(ABOUT) .about(ABOUT)
.version(crate_version!()) .version(crate_version!())
.override_usage(format_usage(USAGE)) .override_usage(format_usage(USAGE))
.setting(AppSettings::InferLongArgs) .infer_long_args(true)
.arg( .arg(
Arg::new(options::ZERO) Arg::new(options::ZERO)
.long(options::ZERO) .long(options::ZERO)

View file

@ -10,7 +10,7 @@ extern crate uucore;
use chrono::prelude::DateTime; use chrono::prelude::DateTime;
use chrono::Local; use chrono::Local;
use clap::{crate_version, App, AppSettings, Arg, ArgMatches}; use clap::{crate_version, Arg, ArgMatches, Command};
use std::collections::HashSet; use std::collections::HashSet;
use std::env; use std::env;
use std::fs; use std::fs;
@ -617,13 +617,13 @@ fn parse_depth(max_depth_str: Option<&str>, summarize: bool) -> UResult<Option<u
} }
} }
pub fn uu_app<'a>() -> App<'a> { pub fn uu_app<'a>() -> Command<'a> {
App::new(uucore::util_name()) Command::new(uucore::util_name())
.version(crate_version!()) .version(crate_version!())
.about(SUMMARY) .about(SUMMARY)
.after_help(LONG_HELP) .after_help(LONG_HELP)
.override_usage(format_usage(USAGE)) .override_usage(format_usage(USAGE))
.setting(AppSettings::InferLongArgs) .infer_long_args(true)
.arg( .arg(
Arg::new(options::ALL) Arg::new(options::ALL)
.short('a') .short('a')

View file

@ -6,7 +6,7 @@
// For the full copyright and license information, please view the LICENSE // For the full copyright and license information, please view the LICENSE
// file that was distributed with this source code. // file that was distributed with this source code.
use clap::{crate_version, App, AppSettings, Arg}; use clap::{crate_version, Arg, Command};
use std::io::{self, Write}; use std::io::{self, Write};
use std::iter::Peekable; use std::iter::Peekable;
use std::str::Chars; use std::str::Chars;
@ -126,15 +126,15 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
.map_err_context(|| "could not write to stdout".to_string()) .map_err_context(|| "could not write to stdout".to_string())
} }
pub fn uu_app<'a>() -> App<'a> { pub fn uu_app<'a>() -> Command<'a> {
App::new(uucore::util_name()) Command::new(uucore::util_name())
.name(NAME) .name(NAME)
// TrailingVarArg specifies the final positional argument is a VarArg // TrailingVarArg specifies the final positional argument is a VarArg
// and it doesn't attempts the parse any further args. // and it doesn't attempts the parse any further args.
// Final argument must have multiple(true) or the usage string equivalent. // Final argument must have multiple(true) or the usage string equivalent.
.setting(AppSettings::TrailingVarArg) .trailing_var_arg(true)
.setting(AppSettings::AllowHyphenValues) .allow_hyphen_values(true)
.setting(AppSettings::InferLongArgs) .infer_long_args(true)
.version(crate_version!()) .version(crate_version!())
.about(SUMMARY) .about(SUMMARY)
.after_help(AFTER_HELP) .after_help(AFTER_HELP)

14
src/uu/env/src/env.rs vendored
View file

@ -16,13 +16,13 @@ extern crate clap;
#[macro_use] #[macro_use]
extern crate uucore; extern crate uucore;
use clap::{App, AppSettings, Arg}; use clap::{Arg, Command};
use ini::Ini; use ini::Ini;
use std::borrow::Cow; use std::borrow::Cow;
use std::env; use std::env;
use std::io::{self, Write}; use std::io::{self, Write};
use std::iter::Iterator; use std::iter::Iterator;
use std::process::Command; use std::process;
use uucore::display::Quotable; use uucore::display::Quotable;
use uucore::error::{UResult, USimpleError, UUsageError}; use uucore::error::{UResult, USimpleError, UUsageError};
use uucore::format_usage; use uucore::format_usage;
@ -121,15 +121,15 @@ fn build_command<'a, 'b>(args: &'a mut Vec<&'b str>) -> (Cow<'b, str>, &'a [&'b
(progname, &args[..]) (progname, &args[..])
} }
pub fn uu_app<'a>() -> App<'a> { pub fn uu_app<'a>() -> Command<'a> {
App::new(crate_name!()) Command::new(crate_name!())
.version(crate_version!()) .version(crate_version!())
.author(crate_authors!()) .author(crate_authors!())
.about(crate_description!()) .about(crate_description!())
.override_usage(format_usage(USAGE)) .override_usage(format_usage(USAGE))
.after_help(AFTER_HELP) .after_help(AFTER_HELP)
.setting(AppSettings::AllowExternalSubcommands) .allow_external_subcommands(true)
.setting(AppSettings::InferLongArgs) .infer_long_args(true)
.arg(Arg::new("ignore-environment") .arg(Arg::new("ignore-environment")
.short('i') .short('i')
.long("ignore-environment") .long("ignore-environment")
@ -307,7 +307,7 @@ fn run_env(args: impl uucore::Args) -> UResult<()> {
* standard library contains many checks and fail-safes to ensure the process ends up being * standard library contains many checks and fail-safes to ensure the process ends up being
* created. This is much simpler than dealing with the hassles of calling execvp directly. * created. This is much simpler than dealing with the hassles of calling execvp directly.
*/ */
match Command::new(&*prog).args(args).status() { match process::Command::new(&*prog).args(args).status() {
Ok(exit) if !exit.success() => return Err(exit.code().unwrap().into()), Ok(exit) if !exit.success() => return Err(exit.code().unwrap().into()),
Err(ref err) if err.kind() == io::ErrorKind::NotFound => return Err(127.into()), Err(ref err) if err.kind() == io::ErrorKind::NotFound => return Err(127.into()),
Err(_) => return Err(126.into()), Err(_) => return Err(126.into()),

View file

@ -12,7 +12,7 @@
#[macro_use] #[macro_use]
extern crate uucore; extern crate uucore;
use clap::{crate_version, App, AppSettings, Arg, ArgMatches}; use clap::{crate_version, Arg, ArgMatches, Command};
use std::fs::File; use std::fs::File;
use std::io::{stdin, stdout, BufRead, BufReader, BufWriter, Read, Write}; use std::io::{stdin, stdout, BufRead, BufReader, BufWriter, Read, Write};
use std::str::from_utf8; use std::str::from_utf8;
@ -176,13 +176,13 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
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())
} }
pub fn uu_app<'a>() -> App<'a> { pub fn uu_app<'a>() -> Command<'a> {
App::new(uucore::util_name()) Command::new(uucore::util_name())
.version(crate_version!()) .version(crate_version!())
.about(ABOUT) .about(ABOUT)
.after_help(LONG_HELP) .after_help(LONG_HELP)
.override_usage(format_usage(USAGE)) .override_usage(format_usage(USAGE))
.setting(AppSettings::InferLongArgs) .infer_long_args(true)
.arg( .arg(
Arg::new(options::INITIAL) Arg::new(options::INITIAL)
.long(options::INITIAL) .long(options::INITIAL)

View file

@ -5,7 +5,7 @@
//* For the full copyright and license information, please view the LICENSE //* For the full copyright and license information, please view the LICENSE
//* file that was distributed with this source code. //* file that was distributed with this source code.
use clap::{crate_version, App, AppSettings, Arg}; use clap::{crate_version, Arg, Command};
use uucore::error::{UResult, USimpleError}; use uucore::error::{UResult, USimpleError};
use uucore::InvalidEncodingHandling; use uucore::InvalidEncodingHandling;
@ -19,12 +19,12 @@ static USAGE: &str = r#"
expr [EXPRESSION] expr [EXPRESSION]
expr [OPTIONS]"#; expr [OPTIONS]"#;
pub fn uu_app<'a>() -> App<'a> { pub fn uu_app<'a>() -> Command<'a> {
App::new(uucore::util_name()) Command::new(uucore::util_name())
.version(crate_version!()) .version(crate_version!())
.about(ABOUT) .about(ABOUT)
.override_usage(USAGE) .override_usage(USAGE)
.setting(AppSettings::InferLongArgs) .infer_long_args(true)
.arg( .arg(
Arg::new(VERSION) Arg::new(VERSION)
.long(VERSION) .long(VERSION)

View file

@ -14,7 +14,7 @@ use std::fmt::Write as FmtWrite;
use std::io::{self, stdin, stdout, BufRead, Write}; use std::io::{self, stdin, stdout, BufRead, Write};
mod factor; mod factor;
use clap::{crate_version, App, AppSettings, Arg}; use clap::{crate_version, Arg, Command};
pub use factor::*; pub use factor::*;
use uucore::display::Quotable; use uucore::display::Quotable;
use uucore::error::UResult; use uucore::error::UResult;
@ -77,10 +77,10 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
Ok(()) Ok(())
} }
pub fn uu_app<'a>() -> App<'a> { pub fn uu_app<'a>() -> Command<'a> {
App::new(uucore::util_name()) Command::new(uucore::util_name())
.version(crate_version!()) .version(crate_version!())
.about(SUMMARY) .about(SUMMARY)
.setting(AppSettings::InferLongArgs) .infer_long_args(true)
.arg(Arg::new(options::NUMBER).multiple_occurrences(true)) .arg(Arg::new(options::NUMBER).multiple_occurrences(true))
} }

View file

@ -4,7 +4,7 @@
// * // *
// * For the full copyright and license information, please view the LICENSE // * For the full copyright and license information, please view the LICENSE
// * file that was distributed with this source code. // * file that was distributed with this source code.
use clap::{App, AppSettings, Arg}; use clap::{Arg, Command};
use std::io::Write; use std::io::Write;
use uucore::error::{set_exit_code, UResult}; use uucore::error::{set_exit_code, UResult};
@ -18,7 +18,7 @@ the program will also return `1`.
#[uucore::main] #[uucore::main]
pub fn uumain(args: impl uucore::Args) -> UResult<()> { pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let mut app = uu_app(); let mut command = uu_app();
// Mirror GNU options, always return `1`. In particular even the 'successful' cases of no-op, // Mirror GNU options, always return `1`. In particular even the 'successful' cases of no-op,
// and the interrupted display of help and version should return `1`. Also, we return Ok in all // and the interrupted display of help and version should return `1`. Also, we return Ok in all
@ -26,11 +26,11 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
// and unwind through the standard library allocation handling machinery. // and unwind through the standard library allocation handling machinery.
set_exit_code(1); set_exit_code(1);
if let Ok(matches) = app.try_get_matches_from_mut(args) { if let Ok(matches) = command.try_get_matches_from_mut(args) {
let error = if matches.index_of("help").is_some() { let error = if matches.index_of("help").is_some() {
app.print_long_help() command.print_long_help()
} else if matches.index_of("version").is_some() { } else if matches.index_of("version").is_some() {
writeln!(std::io::stdout(), "{}", app.render_version()) writeln!(std::io::stdout(), "{}", command.render_version())
} else { } else {
Ok(()) Ok(())
}; };
@ -45,12 +45,13 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
Ok(()) Ok(())
} }
pub fn uu_app<'a>() -> App<'a> { pub fn uu_app<'a>() -> Command<'a> {
App::new(uucore::util_name()) Command::new(uucore::util_name())
.version(clap::crate_version!()) .version(clap::crate_version!())
.about(ABOUT) .about(ABOUT)
// We provide our own help and version options, to ensure maximum compatibility with GNU. // We provide our own help and version options, to ensure maximum compatibility with GNU.
.setting(AppSettings::DisableHelpFlag | AppSettings::DisableVersionFlag) .disable_help_flag(true)
.disable_version_flag(true)
.arg( .arg(
Arg::new("help") Arg::new("help")
.long("help") .long("help")

View file

@ -10,7 +10,7 @@
#[macro_use] #[macro_use]
extern crate uucore; extern crate uucore;
use clap::{crate_version, App, AppSettings, Arg}; use clap::{crate_version, Arg, Command};
use std::cmp; use std::cmp;
use std::fs::File; use std::fs::File;
use std::io::{stdin, stdout, Write}; use std::io::{stdin, stdout, Write};
@ -218,12 +218,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
Ok(()) Ok(())
} }
pub fn uu_app<'a>() -> App<'a> { pub fn uu_app<'a>() -> Command<'a> {
App::new(uucore::util_name()) Command::new(uucore::util_name())
.version(crate_version!()) .version(crate_version!())
.about(ABOUT) .about(ABOUT)
.override_usage(format_usage(USAGE)) .override_usage(format_usage(USAGE))
.setting(AppSettings::InferLongArgs) .infer_long_args(true)
.arg( .arg(
Arg::new(OPT_CROWN_MARGIN) Arg::new(OPT_CROWN_MARGIN)
.short('c') .short('c')

View file

@ -7,7 +7,7 @@
// spell-checker:ignore (ToDOs) ncount routput // spell-checker:ignore (ToDOs) ncount routput
use clap::{crate_version, App, AppSettings, Arg}; use clap::{crate_version, Arg, Command};
use std::fs::File; use std::fs::File;
use std::io::{stdin, BufRead, BufReader, Read}; use std::io::{stdin, BufRead, BufReader, Read};
use std::path::Path; use std::path::Path;
@ -63,13 +63,13 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
fold(&files, bytes, spaces, width) fold(&files, bytes, spaces, width)
} }
pub fn uu_app<'a>() -> App<'a> { pub fn uu_app<'a>() -> Command<'a> {
App::new(uucore::util_name()) Command::new(uucore::util_name())
.name(NAME) .name(NAME)
.version(crate_version!()) .version(crate_version!())
.override_usage(format_usage(USAGE)) .override_usage(format_usage(USAGE))
.about(SUMMARY) .about(SUMMARY)
.setting(AppSettings::InferLongArgs) .infer_long_args(true)
.arg( .arg(
Arg::new(options::BYTES) Arg::new(options::BYTES)
.long(options::BYTES) .long(options::BYTES)

View file

@ -26,7 +26,7 @@ use uucore::{
format_usage, format_usage,
}; };
use clap::{crate_version, App, AppSettings, Arg}; use clap::{crate_version, Arg, Command};
mod options { mod options {
pub const USERS: &str = "USERNAME"; pub const USERS: &str = "USERNAME";
@ -102,12 +102,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
Ok(()) Ok(())
} }
pub fn uu_app<'a>() -> App<'a> { pub fn uu_app<'a>() -> Command<'a> {
App::new(uucore::util_name()) Command::new(uucore::util_name())
.version(crate_version!()) .version(crate_version!())
.about(ABOUT) .about(ABOUT)
.override_usage(format_usage(USAGE)) .override_usage(format_usage(USAGE))
.setting(AppSettings::InferLongArgs) .infer_long_args(true)
.arg( .arg(
Arg::new(options::USERS) Arg::new(options::USERS)
.multiple_occurrences(true) .multiple_occurrences(true)

View file

@ -20,7 +20,7 @@ mod digest;
use self::digest::Digest; use self::digest::Digest;
use self::digest::DigestWriter; use self::digest::DigestWriter;
use clap::{App, AppSettings, Arg, ArgMatches}; use clap::{Arg, ArgMatches, Command};
use hex::encode; use hex::encode;
use md5::Md5; use md5::Md5;
use regex::Regex; use regex::Regex;
@ -297,13 +297,13 @@ pub fn uumain(mut args: impl uucore::Args) -> UResult<()> {
// Default binary in Windows, text mode otherwise // Default binary in Windows, text mode otherwise
let binary_flag_default = cfg!(windows); let binary_flag_default = cfg!(windows);
let app = uu_app(&binary_name); let command = uu_app(&binary_name);
// FIXME: this should use try_get_matches_from() and crash!(), but at the moment that just // FIXME: this should use try_get_matches_from() and crash!(), but at the moment that just
// 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 = app.get_matches_from(args); let matches = command.get_matches_from(args);
let (name, algo, bits) = detect_algo(&binary_name, &matches); let (name, algo, bits) = detect_algo(&binary_name, &matches);
@ -340,7 +340,7 @@ pub fn uumain(mut args: impl uucore::Args) -> UResult<()> {
} }
} }
pub fn uu_app_common<'a>() -> App<'a> { pub fn uu_app_common<'a>() -> Command<'a> {
#[cfg(windows)] #[cfg(windows)]
const BINARY_HELP: &str = "read in binary mode (default)"; const BINARY_HELP: &str = "read in binary mode (default)";
#[cfg(not(windows))] #[cfg(not(windows))]
@ -349,10 +349,10 @@ pub fn uu_app_common<'a>() -> App<'a> {
const TEXT_HELP: &str = "read in text mode"; const TEXT_HELP: &str = "read in text mode";
#[cfg(not(windows))] #[cfg(not(windows))]
const TEXT_HELP: &str = "read in text mode (default)"; const TEXT_HELP: &str = "read in text mode (default)";
App::new(uucore::util_name()) Command::new(uucore::util_name())
.version(crate_version!()) .version(crate_version!())
.about("Compute and check message digests.") .about("Compute and check message digests.")
.setting(AppSettings::InferLongArgs) .infer_long_args(true)
.arg( .arg(
Arg::new("binary") Arg::new("binary")
.short('b') .short('b')
@ -419,8 +419,8 @@ pub fn uu_app_common<'a>() -> App<'a> {
) )
} }
pub fn uu_app_custom<'a>() -> App<'a> { pub fn uu_app_custom<'a>() -> Command<'a> {
let mut app = uu_app_common(); let mut command = uu_app_common();
let algorithms = &[ let algorithms = &[
("md5", "work with MD5"), ("md5", "work with MD5"),
("sha1", "work with SHA1"), ("sha1", "work with SHA1"),
@ -446,14 +446,14 @@ pub fn uu_app_custom<'a>() -> App<'a> {
]; ];
for (name, desc) in algorithms { for (name, desc) in algorithms {
app = app.arg(Arg::new(*name).long(name).help(*desc)); command = command.arg(Arg::new(*name).long(name).help(*desc));
} }
app command
} }
// hashsum is handled differently in build.rs, therefore this is not the same // hashsum is handled differently in build.rs, therefore this is not the same
// as in other utilities. // as in other utilities.
fn uu_app<'a>(binary_name: &str) -> App<'a> { fn uu_app<'a>(binary_name: &str) -> Command<'a> {
if !is_custom_binary(binary_name) { if !is_custom_binary(binary_name) {
uu_app_custom() uu_app_custom()
} else { } else {

View file

@ -5,7 +5,7 @@
// spell-checker:ignore (vars) zlines BUFWRITER seekable // spell-checker:ignore (vars) zlines BUFWRITER seekable
use clap::{crate_version, App, AppSettings, Arg, ArgMatches}; use clap::{crate_version, Arg, ArgMatches, Command};
use std::convert::{TryFrom, TryInto}; use std::convert::{TryFrom, TryInto};
use std::ffi::OsString; use std::ffi::OsString;
use std::io::{self, BufWriter, ErrorKind, Read, Seek, SeekFrom, Write}; use std::io::{self, BufWriter, ErrorKind, Read, Seek, SeekFrom, Write};
@ -41,12 +41,12 @@ mod take;
use take::take_all_but; use take::take_all_but;
use take::take_lines; use take::take_lines;
pub fn uu_app<'a>() -> App<'a> { pub fn uu_app<'a>() -> Command<'a> {
App::new(uucore::util_name()) Command::new(uucore::util_name())
.version(crate_version!()) .version(crate_version!())
.about(ABOUT) .about(ABOUT)
.override_usage(format_usage(USAGE)) .override_usage(format_usage(USAGE))
.setting(AppSettings::InferLongArgs) .infer_long_args(true)
.arg( .arg(
Arg::new(options::BYTES_NAME) Arg::new(options::BYTES_NAME)
.short('c') .short('c')

View file

@ -7,7 +7,7 @@
// spell-checker:ignore (ToDO) gethostid // spell-checker:ignore (ToDO) gethostid
use clap::{crate_version, App, AppSettings}; use clap::{crate_version, Command};
use libc::c_long; use libc::c_long;
use uucore::{error::UResult, format_usage}; use uucore::{error::UResult, format_usage};
@ -26,12 +26,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
Ok(()) Ok(())
} }
pub fn uu_app<'a>() -> App<'a> { pub fn uu_app<'a>() -> Command<'a> {
App::new(uucore::util_name()) Command::new(uucore::util_name())
.version(crate_version!()) .version(crate_version!())
.about(SUMMARY) .about(SUMMARY)
.override_usage(format_usage(USAGE)) .override_usage(format_usage(USAGE))
.setting(AppSettings::InferLongArgs) .infer_long_args(true)
} }
fn hostid() { fn hostid() {

View file

@ -11,7 +11,7 @@ use std::collections::hash_set::HashSet;
use std::net::ToSocketAddrs; use std::net::ToSocketAddrs;
use std::str; use std::str;
use clap::{crate_version, App, AppSettings, Arg, ArgMatches}; use clap::{crate_version, Arg, ArgMatches, Command};
use uucore::{ use uucore::{
error::{FromIo, UResult}, error::{FromIo, UResult},
@ -71,12 +71,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
} }
} }
pub fn uu_app<'a>() -> App<'a> { pub fn uu_app<'a>() -> Command<'a> {
App::new(uucore::util_name()) Command::new(uucore::util_name())
.version(crate_version!()) .version(crate_version!())
.about(ABOUT) .about(ABOUT)
.override_usage(format_usage(USAGE)) .override_usage(format_usage(USAGE))
.setting(AppSettings::InferLongArgs) .infer_long_args(true)
.arg( .arg(
Arg::new(OPT_DOMAIN) Arg::new(OPT_DOMAIN)
.short('d') .short('d')

View file

@ -39,7 +39,7 @@
#[macro_use] #[macro_use]
extern crate uucore; extern crate uucore;
use clap::{crate_version, App, AppSettings, Arg}; use clap::{crate_version, Arg, Command};
use std::ffi::CStr; use std::ffi::CStr;
use uucore::display::Quotable; use uucore::display::Quotable;
use uucore::entries::{self, Group, Locate, Passwd}; use uucore::entries::{self, Group, Locate, Passwd};
@ -341,12 +341,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
Ok(()) Ok(())
} }
pub fn uu_app<'a>() -> App<'a> { pub fn uu_app<'a>() -> Command<'a> {
App::new(uucore::util_name()) Command::new(uucore::util_name())
.version(crate_version!()) .version(crate_version!())
.about(ABOUT) .about(ABOUT)
.override_usage(format_usage(USAGE)) .override_usage(format_usage(USAGE))
.setting(AppSettings::InferLongArgs) .infer_long_args(true)
.arg( .arg(
Arg::new(options::OPT_AUDIT) Arg::new(options::OPT_AUDIT)
.short('A') .short('A')

View file

@ -12,7 +12,7 @@ mod mode;
#[macro_use] #[macro_use]
extern crate uucore; extern crate uucore;
use clap::{crate_version, App, AppSettings, Arg, ArgMatches}; use clap::{crate_version, Arg, ArgMatches, Command};
use file_diff::diff; use file_diff::diff;
use filetime::{set_file_times, FileTime}; use filetime::{set_file_times, FileTime};
use uucore::backup_control::{self, BackupMode}; use uucore::backup_control::{self, BackupMode};
@ -30,7 +30,7 @@ use std::fs;
use std::fs::File; use std::fs::File;
use std::os::unix::fs::MetadataExt; use std::os::unix::fs::MetadataExt;
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use std::process::Command; use std::process;
const DEFAULT_MODE: u32 = 0o755; const DEFAULT_MODE: u32 = 0o755;
const DEFAULT_STRIP_PROGRAM: &str = "strip"; const DEFAULT_STRIP_PROGRAM: &str = "strip";
@ -188,12 +188,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
} }
} }
pub fn uu_app<'a>() -> App<'a> { pub fn uu_app<'a>() -> Command<'a> {
App::new(uucore::util_name()) Command::new(uucore::util_name())
.version(crate_version!()) .version(crate_version!())
.about(ABOUT) .about(ABOUT)
.override_usage(format_usage(USAGE)) .override_usage(format_usage(USAGE))
.setting(AppSettings::InferLongArgs) .infer_long_args(true)
.arg( .arg(
backup_control::arguments::backup() backup_control::arguments::backup()
) )
@ -585,7 +585,7 @@ fn copy(from: &Path, to: &Path, b: &Behavior) -> UResult<()> {
} }
if b.strip && cfg!(not(windows)) { if b.strip && cfg!(not(windows)) {
match Command::new(&b.strip_program).arg(to).output() { match process::Command::new(&b.strip_program).arg(to).output() {
Ok(o) => { Ok(o) => {
if !o.status.success() { if !o.status.success() {
return Err(InstallError::StripProgramFailed( return Err(InstallError::StripProgramFailed(

View file

@ -10,7 +10,7 @@
#[macro_use] #[macro_use]
extern crate uucore; extern crate uucore;
use clap::{crate_version, App, AppSettings, Arg}; use clap::{crate_version, Arg, Command};
use memchr::{memchr3_iter, memchr_iter}; use memchr::{memchr3_iter, memchr_iter};
use std::cmp::Ordering; use std::cmp::Ordering;
use std::convert::From; use std::convert::From;
@ -697,8 +697,8 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
} }
} }
pub fn uu_app<'a>() -> App<'a> { pub fn uu_app<'a>() -> Command<'a> {
App::new(NAME) Command::new(NAME)
.version(crate_version!()) .version(crate_version!())
.about( .about(
"For each pair of input lines with identical join fields, write a line to "For each pair of input lines with identical join fields, write a line to
@ -706,7 +706,7 @@ standard output. The default join field is the first, delimited by blanks.
When FILE1 or FILE2 (not both) is -, read standard input.", When FILE1 or FILE2 (not both) is -, read standard input.",
) )
.setting(AppSettings::InferLongArgs) .infer_long_args(true)
.arg( .arg(
Arg::new("a") Arg::new("a")
.short('a') .short('a')

View file

@ -10,7 +10,7 @@
#[macro_use] #[macro_use]
extern crate uucore; extern crate uucore;
use clap::{crate_version, App, AppSettings, Arg}; use clap::{crate_version, Arg, Command};
use libc::{c_int, pid_t}; use libc::{c_int, pid_t};
use std::io::Error; use std::io::Error;
use uucore::display::Quotable; use uucore::display::Quotable;
@ -78,12 +78,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
} }
} }
pub fn uu_app<'a>() -> App<'a> { pub fn uu_app<'a>() -> Command<'a> {
App::new(uucore::util_name()) Command::new(uucore::util_name())
.version(crate_version!()) .version(crate_version!())
.about(ABOUT) .about(ABOUT)
.override_usage(format_usage(USAGE)) .override_usage(format_usage(USAGE))
.setting(AppSettings::InferLongArgs) .infer_long_args(true)
.arg( .arg(
Arg::new(options::LIST) Arg::new(options::LIST)
.short('l') .short('l')

View file

@ -4,7 +4,7 @@
// * // *
// * For the full copyright and license information, please view the LICENSE // * For the full copyright and license information, please view the LICENSE
// * file that was distributed with this source code. // * file that was distributed with this source code.
use clap::{crate_version, App, AppSettings, Arg}; use clap::{crate_version, Arg, Command};
use std::fs::hard_link; use std::fs::hard_link;
use std::path::Path; use std::path::Path;
use uucore::display::Quotable; use uucore::display::Quotable;
@ -33,12 +33,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
.map_err_context(|| format!("cannot create link {} to {}", new.quote(), old.quote())) .map_err_context(|| format!("cannot create link {} to {}", new.quote(), old.quote()))
} }
pub fn uu_app<'a>() -> App<'a> { pub fn uu_app<'a>() -> Command<'a> {
App::new(uucore::util_name()) Command::new(uucore::util_name())
.version(crate_version!()) .version(crate_version!())
.about(ABOUT) .about(ABOUT)
.override_usage(format_usage(USAGE)) .override_usage(format_usage(USAGE))
.setting(AppSettings::InferLongArgs) .infer_long_args(true)
.arg( .arg(
Arg::new(options::FILES) Arg::new(options::FILES)
.hide(true) .hide(true)

View file

@ -10,7 +10,7 @@
#[macro_use] #[macro_use]
extern crate uucore; extern crate uucore;
use clap::{crate_version, App, AppSettings, Arg}; use clap::{crate_version, Arg, Command};
use uucore::display::Quotable; use uucore::display::Quotable;
use uucore::error::{UError, UResult}; use uucore::error::{UError, UResult};
use uucore::format_usage; use uucore::format_usage;
@ -173,12 +173,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
exec(&paths[..], &settings) exec(&paths[..], &settings)
} }
pub fn uu_app<'a>() -> App<'a> { pub fn uu_app<'a>() -> Command<'a> {
App::new(uucore::util_name()) Command::new(uucore::util_name())
.version(crate_version!()) .version(crate_version!())
.about(ABOUT) .about(ABOUT)
.override_usage(format_usage(USAGE)) .override_usage(format_usage(USAGE))
.setting(AppSettings::InferLongArgs) .infer_long_args(true)
.arg(backup_control::arguments::backup()) .arg(backup_control::arguments::backup())
.arg(backup_control::arguments::backup_no_args()) .arg(backup_control::arguments::backup_no_args())
// TODO: opts.arg( // TODO: opts.arg(

View file

@ -12,7 +12,7 @@
#[macro_use] #[macro_use]
extern crate uucore; extern crate uucore;
use clap::{crate_version, App, AppSettings}; use clap::{crate_version, Command};
use std::ffi::CStr; use std::ffi::CStr;
use uucore::error::UResult; use uucore::error::UResult;
use uucore::InvalidEncodingHandling; use uucore::InvalidEncodingHandling;
@ -51,10 +51,10 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
Ok(()) Ok(())
} }
pub fn uu_app<'a>() -> App<'a> { pub fn uu_app<'a>() -> Command<'a> {
App::new(uucore::util_name()) Command::new(uucore::util_name())
.version(crate_version!()) .version(crate_version!())
.override_usage(uucore::execution_phrase()) .override_usage(uucore::execution_phrase())
.about(SUMMARY) .about(SUMMARY)
.setting(AppSettings::InferLongArgs) .infer_long_args(true)
} }

View file

@ -15,7 +15,7 @@ extern crate lazy_static;
mod quoting_style; mod quoting_style;
use clap::{crate_version, App, AppSettings, Arg}; use clap::{crate_version, Arg, Command};
use glob::Pattern; use glob::Pattern;
use lscolors::LsColors; use lscolors::LsColors;
use number_prefix::NumberPrefix; use number_prefix::NumberPrefix;
@ -782,9 +782,9 @@ impl Config {
#[uucore::main] #[uucore::main]
pub fn uumain(args: impl uucore::Args) -> UResult<()> { pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let app = uu_app(); let command = uu_app();
let matches = app.get_matches_from(args); let matches = command.get_matches_from(args);
let config = Config::from(&matches)?; let config = Config::from(&matches)?;
@ -796,8 +796,8 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
list(locs, &config) list(locs, &config)
} }
pub fn uu_app<'a>() -> App<'a> { pub fn uu_app<'a>() -> Command<'a> {
App::new(uucore::util_name()) Command::new(uucore::util_name())
.version(crate_version!()) .version(crate_version!())
.override_usage(format_usage(USAGE)) .override_usage(format_usage(USAGE))
.about( .about(
@ -805,7 +805,7 @@ pub fn uu_app<'a>() -> App<'a> {
the command line, expect that it will ignore files and directories \ the command line, expect that it will ignore files and directories \
whose names start with '.'.", whose names start with '.'.",
) )
.setting(AppSettings::InferLongArgs) .infer_long_args(true)
// Format arguments // Format arguments
.arg( .arg(
Arg::new(options::FORMAT) Arg::new(options::FORMAT)

View file

@ -10,7 +10,7 @@
#[macro_use] #[macro_use]
extern crate uucore; extern crate uucore;
use clap::{crate_version, App, AppSettings, Arg, ArgMatches, OsValues}; use clap::{crate_version, Arg, ArgMatches, Command, OsValues};
use std::path::Path; use std::path::Path;
use uucore::display::Quotable; use uucore::display::Quotable;
#[cfg(not(windows))] #[cfg(not(windows))]
@ -104,12 +104,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
} }
} }
pub fn uu_app<'a>() -> App<'a> { pub fn uu_app<'a>() -> Command<'a> {
App::new(uucore::util_name()) Command::new(uucore::util_name())
.version(crate_version!()) .version(crate_version!())
.about(ABOUT) .about(ABOUT)
.override_usage(format_usage(USAGE)) .override_usage(format_usage(USAGE))
.setting(AppSettings::InferLongArgs) .infer_long_args(true)
.arg( .arg(
Arg::new(options::MODE) Arg::new(options::MODE)
.short('m') .short('m')

View file

@ -8,7 +8,7 @@
#[macro_use] #[macro_use]
extern crate uucore; extern crate uucore;
use clap::{crate_version, App, AppSettings, Arg}; use clap::{crate_version, Arg, Command};
use libc::mkfifo; use libc::mkfifo;
use std::ffi::CString; use std::ffi::CString;
use uucore::error::{UResult, USimpleError}; use uucore::error::{UResult, USimpleError};
@ -70,13 +70,13 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
Ok(()) Ok(())
} }
pub fn uu_app<'a>() -> App<'a> { pub fn uu_app<'a>() -> Command<'a> {
App::new(uucore::util_name()) Command::new(uucore::util_name())
.name(NAME) .name(NAME)
.version(crate_version!()) .version(crate_version!())
.override_usage(format_usage(USAGE)) .override_usage(format_usage(USAGE))
.about(SUMMARY) .about(SUMMARY)
.setting(AppSettings::InferLongArgs) .infer_long_args(true)
.arg( .arg(
Arg::new(options::MODE) Arg::new(options::MODE)
.short('m') .short('m')

View file

@ -9,7 +9,7 @@
use std::ffi::CString; use std::ffi::CString;
use clap::{crate_version, App, AppSettings, Arg, ArgMatches}; use clap::{crate_version, Arg, ArgMatches, Command};
use libc::{dev_t, mode_t}; use libc::{dev_t, mode_t};
use libc::{S_IFBLK, S_IFCHR, S_IFIFO, S_IRGRP, S_IROTH, S_IRUSR, S_IWGRP, S_IWOTH, S_IWUSR}; use libc::{S_IFBLK, S_IFCHR, S_IFIFO, S_IRGRP, S_IROTH, S_IRUSR, S_IWGRP, S_IWOTH, S_IWUSR};
@ -143,13 +143,13 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
} }
} }
pub fn uu_app<'a>() -> App<'a> { pub fn uu_app<'a>() -> Command<'a> {
App::new(uucore::util_name()) Command::new(uucore::util_name())
.version(crate_version!()) .version(crate_version!())
.override_usage(format_usage(USAGE)) .override_usage(format_usage(USAGE))
.after_help(LONG_HELP) .after_help(LONG_HELP)
.about(ABOUT) .about(ABOUT)
.setting(AppSettings::InferLongArgs) .infer_long_args(true)
.arg( .arg(
Arg::new("mode") Arg::new("mode")
.short('m') .short('m')

View file

@ -8,7 +8,7 @@
// spell-checker:ignore (paths) GPGHome // spell-checker:ignore (paths) GPGHome
use clap::{crate_version, App, AppSettings, Arg}; use clap::{crate_version, Arg, Command};
use uucore::display::{println_verbatim, Quotable}; use uucore::display::{println_verbatim, Quotable};
use uucore::error::{FromIo, UError, UResult}; use uucore::error::{FromIo, UError, UResult};
use uucore::format_usage; use uucore::format_usage;
@ -131,12 +131,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
} }
} }
pub fn uu_app<'a>() -> App<'a> { pub fn uu_app<'a>() -> Command<'a> {
App::new(uucore::util_name()) Command::new(uucore::util_name())
.version(crate_version!()) .version(crate_version!())
.about(ABOUT) .about(ABOUT)
.override_usage(format_usage(USAGE)) .override_usage(format_usage(USAGE))
.setting(AppSettings::InferLongArgs) .infer_long_args(true)
.arg( .arg(
Arg::new(OPT_DIRECTORY) Arg::new(OPT_DIRECTORY)
.short('d') .short('d')

View file

@ -17,7 +17,7 @@ use std::{
#[cfg(all(unix, not(target_os = "fuchsia")))] #[cfg(all(unix, not(target_os = "fuchsia")))]
extern crate nix; extern crate nix;
use clap::{crate_version, App, AppSettings, Arg}; use clap::{crate_version, Arg, Command};
use crossterm::{ use crossterm::{
event::{self, Event, KeyCode, KeyEvent, KeyModifiers}, event::{self, Event, KeyCode, KeyEvent, KeyModifiers},
execute, queue, execute, queue,
@ -96,11 +96,11 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
Ok(()) Ok(())
} }
pub fn uu_app<'a>() -> App<'a> { pub fn uu_app<'a>() -> Command<'a> {
App::new(uucore::util_name()) Command::new(uucore::util_name())
.about("A file perusal filter for CRT viewing.") .about("A file perusal filter for CRT viewing.")
.version(crate_version!()) .version(crate_version!())
.setting(AppSettings::InferLongArgs) .infer_long_args(true)
.arg( .arg(
Arg::new(options::SILENT) Arg::new(options::SILENT)
.short('d') .short('d')

View file

@ -13,7 +13,7 @@ mod error;
#[macro_use] #[macro_use]
extern crate uucore; extern crate uucore;
use clap::{crate_version, App, AppSettings, Arg, ArgMatches}; use clap::{crate_version, Arg, ArgMatches, Command};
use std::env; use std::env;
use std::ffi::OsString; use std::ffi::OsString;
use std::fs; use std::fs;
@ -112,12 +112,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
exec(&files[..], &behavior) exec(&files[..], &behavior)
} }
pub fn uu_app<'a>() -> App<'a> { pub fn uu_app<'a>() -> Command<'a> {
App::new(uucore::util_name()) Command::new(uucore::util_name())
.version(crate_version!()) .version(crate_version!())
.about(ABOUT) .about(ABOUT)
.override_usage(format_usage(USAGE)) .override_usage(format_usage(USAGE))
.setting(AppSettings::InferLongArgs) .infer_long_args(true)
.arg( .arg(
backup_control::arguments::backup() backup_control::arguments::backup()
) )

View file

@ -15,7 +15,7 @@ use std::ffi::CString;
use std::io::Error; use std::io::Error;
use std::ptr; use std::ptr;
use clap::{crate_version, App, AppSettings, Arg}; use clap::{crate_version, Arg, Command};
use uucore::{ use uucore::{
error::{set_exit_code, UResult, USimpleError, UUsageError}, error::{set_exit_code, UResult, USimpleError, UUsageError},
format_usage, format_usage,
@ -102,12 +102,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
Ok(()) Ok(())
} }
pub fn uu_app<'a>() -> App<'a> { pub fn uu_app<'a>() -> Command<'a> {
App::new(uucore::util_name()) Command::new(uucore::util_name())
.about(ABOUT) .about(ABOUT)
.override_usage(format_usage(USAGE)) .override_usage(format_usage(USAGE))
.setting(AppSettings::TrailingVarArg) .trailing_var_arg(true)
.setting(AppSettings::InferLongArgs) .infer_long_args(true)
.version(crate_version!()) .version(crate_version!())
.arg( .arg(
Arg::new(options::ADJUSTMENT) Arg::new(options::ADJUSTMENT)

View file

@ -8,7 +8,7 @@
// spell-checker:ignore (ToDO) corasick memchr // spell-checker:ignore (ToDO) corasick memchr
use clap::{crate_version, App, AppSettings, Arg}; use clap::{crate_version, Arg, Command};
use std::fs::File; use std::fs::File;
use std::io::{stdin, BufRead, BufReader, Read}; use std::io::{stdin, BufRead, BufReader, Read};
use std::iter::repeat; use std::iter::repeat;
@ -139,12 +139,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
Ok(()) Ok(())
} }
pub fn uu_app<'a>() -> App<'a> { pub fn uu_app<'a>() -> Command<'a> {
App::new(uucore::util_name()) Command::new(uucore::util_name())
.name(NAME) .name(NAME)
.version(crate_version!()) .version(crate_version!())
.override_usage(format_usage(USAGE)) .override_usage(format_usage(USAGE))
.setting(AppSettings::InferLongArgs) .infer_long_args(true)
.arg( .arg(
Arg::new(options::FILE) Arg::new(options::FILE)
.hide(true) .hide(true)

View file

@ -10,7 +10,7 @@
#[macro_use] #[macro_use]
extern crate uucore; extern crate uucore;
use clap::{crate_version, App, AppSettings, Arg}; use clap::{crate_version, Arg, Command};
use libc::{c_char, dup2, execvp, signal}; use libc::{c_char, dup2, execvp, signal};
use libc::{SIGHUP, SIG_IGN}; use libc::{SIGHUP, SIG_IGN};
use std::env; use std::env;
@ -116,8 +116,8 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
Ok(()) Ok(())
} }
pub fn uu_app<'a>() -> App<'a> { pub fn uu_app<'a>() -> Command<'a> {
App::new(uucore::util_name()) Command::new(uucore::util_name())
.version(crate_version!()) .version(crate_version!())
.about(ABOUT) .about(ABOUT)
.after_help(LONG_HELP) .after_help(LONG_HELP)
@ -128,8 +128,8 @@ pub fn uu_app<'a>() -> App<'a> {
.required(true) .required(true)
.multiple_occurrences(true), .multiple_occurrences(true),
) )
.setting(AppSettings::TrailingVarArg) .trailing_var_arg(true)
.setting(AppSettings::InferLongArgs) .infer_long_args(true)
} }
fn replace_fds() -> UResult<()> { fn replace_fds() -> UResult<()> {

View file

@ -7,7 +7,7 @@
// spell-checker:ignore (ToDO) NPROCESSORS nprocs numstr threadstr sysconf // spell-checker:ignore (ToDO) NPROCESSORS nprocs numstr threadstr sysconf
use clap::{crate_version, App, AppSettings, Arg}; use clap::{crate_version, Arg, Command};
use std::env; use std::env;
use uucore::display::Quotable; use uucore::display::Quotable;
use uucore::error::{UResult, USimpleError}; use uucore::error::{UResult, USimpleError};
@ -68,12 +68,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
Ok(()) Ok(())
} }
pub fn uu_app<'a>() -> App<'a> { pub fn uu_app<'a>() -> Command<'a> {
App::new(uucore::util_name()) Command::new(uucore::util_name())
.version(crate_version!()) .version(crate_version!())
.about(ABOUT) .about(ABOUT)
.override_usage(format_usage(USAGE)) .override_usage(format_usage(USAGE))
.setting(AppSettings::InferLongArgs) .infer_long_args(true)
.arg( .arg(
Arg::new(OPT_ALL) Arg::new(OPT_ALL)
.long(OPT_ALL) .long(OPT_ALL)

View file

@ -11,7 +11,7 @@ use crate::errors::*;
use crate::format::format_and_print; use crate::format::format_and_print;
use crate::options::*; use crate::options::*;
use crate::units::{Result, Unit}; use crate::units::{Result, Unit};
use clap::{crate_version, App, AppSettings, Arg, ArgMatches}; use clap::{crate_version, Arg, ArgMatches, Command};
use std::io::{BufRead, Write}; use std::io::{BufRead, Write};
use uucore::display::Quotable; use uucore::display::Quotable;
use uucore::error::UResult; use uucore::error::UResult;
@ -186,14 +186,14 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
} }
} }
pub fn uu_app<'a>() -> App<'a> { pub fn uu_app<'a>() -> Command<'a> {
App::new(uucore::util_name()) Command::new(uucore::util_name())
.version(crate_version!()) .version(crate_version!())
.about(ABOUT) .about(ABOUT)
.after_help(LONG_HELP) .after_help(LONG_HELP)
.override_usage(format_usage(USAGE)) .override_usage(format_usage(USAGE))
.setting(AppSettings::AllowNegativeNumbers) .allow_negative_numbers(true)
.setting(AppSettings::InferLongArgs) .infer_long_args(true)
.arg( .arg(
Arg::new(options::DELIMITER) Arg::new(options::DELIMITER)
.short('d') .short('d')

View file

@ -5,7 +5,7 @@
// * For the full copyright and license information, please view the LICENSE // * For the full copyright and license information, please view the LICENSE
// * file that was distributed with this source code. // * file that was distributed with this source code.
// spell-checker:ignore (clap) DontDelimitTrailingValues // spell-checker:ignore (clap) dont
// spell-checker:ignore (ToDO) formatteriteminfo inputdecoder inputoffset mockstream nrofbytes partialreader odfunc multifile exitcode // spell-checker:ignore (ToDO) formatteriteminfo inputdecoder inputoffset mockstream nrofbytes partialreader odfunc multifile exitcode
#[macro_use] #[macro_use]
@ -43,7 +43,7 @@ use crate::parse_nrofbytes::parse_number_of_bytes;
use crate::partialreader::*; use crate::partialreader::*;
use crate::peekreader::*; use crate::peekreader::*;
use crate::prn_char::format_ascii_dump; use crate::prn_char::format_ascii_dump;
use clap::{crate_version, App, AppSettings, Arg, ArgMatches}; use clap::{crate_version, AppSettings, Arg, ArgMatches, Command};
use uucore::display::Quotable; use uucore::display::Quotable;
use uucore::error::{UResult, USimpleError}; use uucore::error::{UResult, USimpleError};
use uucore::format_usage; use uucore::format_usage;
@ -289,18 +289,16 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
odfunc(&mut input_offset, &mut input_decoder, &output_info) odfunc(&mut input_offset, &mut input_decoder, &output_info)
} }
pub fn uu_app<'a>() -> App<'a> { pub fn uu_app<'a>() -> Command<'a> {
App::new(uucore::util_name()) Command::new(uucore::util_name())
.version(crate_version!()) .version(crate_version!())
.about(ABOUT) .about(ABOUT)
.override_usage(format_usage(USAGE)) .override_usage(format_usage(USAGE))
.after_help(LONG_HELP) .after_help(LONG_HELP)
.setting( .trailing_var_arg(true)
AppSettings::TrailingVarArg | .dont_delimit_trailing_values(true)
AppSettings::DontDelimitTrailingValues | .infer_long_args(true)
AppSettings::DeriveDisplayOrder | .setting(AppSettings::DeriveDisplayOrder)
AppSettings::InferLongArgs
)
.arg( .arg(
Arg::new(options::ADDRESS_RADIX) Arg::new(options::ADDRESS_RADIX)
.short('A') .short('A')

View file

@ -7,7 +7,7 @@
// spell-checker:ignore (ToDO) delim // spell-checker:ignore (ToDO) delim
use clap::{crate_version, App, AppSettings, Arg}; use clap::{crate_version, Arg, Command};
use std::fs::File; use std::fs::File;
use std::io::{stdin, stdout, BufRead, BufReader, Read, Write}; use std::io::{stdin, stdout, BufRead, BufReader, Read, Write};
use std::path::Path; use std::path::Path;
@ -47,11 +47,11 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
paste(files, serial, delimiters) paste(files, serial, delimiters)
} }
pub fn uu_app<'a>() -> App<'a> { pub fn uu_app<'a>() -> Command<'a> {
App::new(uucore::util_name()) Command::new(uucore::util_name())
.version(crate_version!()) .version(crate_version!())
.about(ABOUT) .about(ABOUT)
.setting(AppSettings::InferLongArgs) .infer_long_args(true)
.arg( .arg(
Arg::new(options::SERIAL) Arg::new(options::SERIAL)
.long(options::SERIAL) .long(options::SERIAL)

View file

@ -8,7 +8,7 @@
// * that was distributed with this source code. // * that was distributed with this source code.
// spell-checker:ignore (ToDO) lstat // spell-checker:ignore (ToDO) lstat
use clap::{crate_version, App, AppSettings, Arg}; use clap::{crate_version, Arg, Command};
use std::fs; use std::fs;
use std::io::{ErrorKind, Write}; use std::io::{ErrorKind, Write};
use uucore::display::Quotable; use uucore::display::Quotable;
@ -84,12 +84,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
Ok(()) Ok(())
} }
pub fn uu_app<'a>() -> App<'a> { pub fn uu_app<'a>() -> Command<'a> {
App::new(uucore::util_name()) Command::new(uucore::util_name())
.version(crate_version!()) .version(crate_version!())
.about(ABOUT) .about(ABOUT)
.override_usage(format_usage(USAGE)) .override_usage(format_usage(USAGE))
.setting(AppSettings::InferLongArgs) .infer_long_args(true)
.arg( .arg(
Arg::new(options::POSIX) Arg::new(options::POSIX)
.short('p') .short('p')

View file

@ -18,7 +18,7 @@ use std::io::BufReader;
use std::fs::File; use std::fs::File;
use std::os::unix::fs::MetadataExt; use std::os::unix::fs::MetadataExt;
use clap::{crate_version, App, AppSettings, Arg}; use clap::{crate_version, Arg, Command};
use std::path::PathBuf; use std::path::PathBuf;
use uucore::{format_usage, InvalidEncodingHandling}; use uucore::{format_usage, InvalidEncodingHandling};
@ -123,12 +123,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
} }
} }
pub fn uu_app<'a>() -> App<'a> { pub fn uu_app<'a>() -> Command<'a> {
App::new(uucore::util_name()) Command::new(uucore::util_name())
.version(crate_version!()) .version(crate_version!())
.about(ABOUT) .about(ABOUT)
.override_usage(format_usage(USAGE)) .override_usage(format_usage(USAGE))
.setting(AppSettings::InferLongArgs) .infer_long_args(true)
.arg( .arg(
Arg::new(options::LONG_FORMAT) Arg::new(options::LONG_FORMAT)
.short('l') .short('l')

View file

@ -11,7 +11,7 @@ extern crate quick_error;
use chrono::offset::Local; use chrono::offset::Local;
use chrono::DateTime; use chrono::DateTime;
use clap::{App, AppSettings, Arg, ArgMatches}; use clap::{AppSettings, Arg, ArgMatches, Command};
use itertools::Itertools; use itertools::Itertools;
use quick_error::ResultExt; use quick_error::ResultExt;
use regex::Regex; use regex::Regex;
@ -192,13 +192,13 @@ quick_error! {
} }
} }
pub fn uu_app<'a>() -> App<'a> { pub fn uu_app<'a>() -> Command<'a> {
App::new(uucore::util_name()) Command::new(uucore::util_name())
.version(VERSION) .version(VERSION)
.about(ABOUT) .about(ABOUT)
.after_help(AFTER_HELP) .after_help(AFTER_HELP)
.setting(AppSettings::InferLongArgs) .infer_long_args(true)
.setting(AppSettings::AllArgsOverrideSelf) .args_override_self(true)
.setting(AppSettings::NoAutoHelp) .setting(AppSettings::NoAutoHelp)
.setting(AppSettings::NoAutoVersion) .setting(AppSettings::NoAutoVersion)
.arg( .arg(
@ -383,8 +383,8 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let opt_args = recreate_arguments(&args); let opt_args = recreate_arguments(&args);
let mut app = uu_app(); let mut command = uu_app();
let matches = match app.try_get_matches_from_mut(opt_args) { let matches = match command.try_get_matches_from_mut(opt_args) {
Ok(m) => m, Ok(m) => m,
Err(e) => { Err(e) => {
e.print()?; e.print()?;
@ -394,12 +394,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
}; };
if matches.is_present(options::VERSION) { if matches.is_present(options::VERSION) {
println!("{}", app.render_long_version()); println!("{}", command.render_long_version());
return Ok(()); return Ok(());
} }
if matches.is_present(options::HELP) { if matches.is_present(options::HELP) {
app.print_long_help()?; command.print_long_help()?;
return Ok(()); return Ok(());
} }

View file

@ -7,7 +7,7 @@
/* last synced with: printenv (GNU coreutils) 8.13 */ /* last synced with: printenv (GNU coreutils) 8.13 */
use clap::{crate_version, App, AppSettings, Arg}; use clap::{crate_version, Arg, Command};
use std::env; use std::env;
use uucore::{error::UResult, format_usage}; use uucore::{error::UResult, format_usage};
@ -56,12 +56,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
} }
} }
pub fn uu_app<'a>() -> App<'a> { pub fn uu_app<'a>() -> Command<'a> {
App::new(uucore::util_name()) Command::new(uucore::util_name())
.version(crate_version!()) .version(crate_version!())
.about(ABOUT) .about(ABOUT)
.override_usage(format_usage(USAGE)) .override_usage(format_usage(USAGE))
.setting(AppSettings::InferLongArgs) .infer_long_args(true)
.arg( .arg(
Arg::new(OPT_NULL) Arg::new(OPT_NULL)
.short('0') .short('0')

View file

@ -2,7 +2,7 @@
// spell-checker:ignore (change!) each's // spell-checker:ignore (change!) each's
// spell-checker:ignore (ToDO) LONGHELP FORMATSTRING templating parameterizing formatstr // spell-checker:ignore (ToDO) LONGHELP FORMATSTRING templating parameterizing formatstr
use clap::{crate_version, App, AppSettings, Arg}; use clap::{crate_version, Arg, Command};
use uucore::error::{UResult, UUsageError}; use uucore::error::{UResult, UUsageError};
use uucore::InvalidEncodingHandling; use uucore::InvalidEncodingHandling;
use uucore::{format_usage, memo}; use uucore::{format_usage, memo};
@ -288,9 +288,9 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
Ok(()) Ok(())
} }
pub fn uu_app<'a>() -> App<'a> { pub fn uu_app<'a>() -> Command<'a> {
App::new(uucore::util_name()) Command::new(uucore::util_name())
.setting(AppSettings::AllowHyphenValues) .allow_hyphen_values(true)
.version(crate_version!()) .version(crate_version!())
.about(ABOUT) .about(ABOUT)
.after_help(AFTER_HELP) .after_help(AFTER_HELP)

View file

@ -7,7 +7,7 @@
// spell-checker:ignore (ToDOs) corasick memchr Roff trunc oset iset // spell-checker:ignore (ToDOs) corasick memchr Roff trunc oset iset
use clap::{crate_version, App, AppSettings, Arg}; use clap::{crate_version, Arg, Command};
use regex::Regex; use regex::Regex;
use std::cmp; use std::cmp;
use std::collections::{BTreeSet, HashMap, HashSet}; use std::collections::{BTreeSet, HashMap, HashSet};
@ -702,13 +702,13 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
write_traditional_output(&config, &file_map, &word_set, &output_file) write_traditional_output(&config, &file_map, &word_set, &output_file)
} }
pub fn uu_app<'a>() -> App<'a> { pub fn uu_app<'a>() -> Command<'a> {
App::new(uucore::util_name()) Command::new(uucore::util_name())
.name(NAME) .name(NAME)
.about(ABOUT) .about(ABOUT)
.version(crate_version!()) .version(crate_version!())
.override_usage(format_usage(USAGE)) .override_usage(format_usage(USAGE))
.setting(AppSettings::InferLongArgs) .infer_long_args(true)
.arg( .arg(
Arg::new(options::FILE) Arg::new(options::FILE)
.hide(true) .hide(true)

View file

@ -5,7 +5,7 @@
// * For the full copyright and license information, please view the LICENSE // * For the full copyright and license information, please view the LICENSE
// * file that was distributed with this source code. // * file that was distributed with this source code.
use clap::{crate_version, App, AppSettings, Arg}; use clap::{crate_version, Arg, Command};
use std::env; use std::env;
use std::io; use std::io;
use std::path::PathBuf; use std::path::PathBuf;
@ -148,12 +148,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
Ok(()) Ok(())
} }
pub fn uu_app<'a>() -> App<'a> { pub fn uu_app<'a>() -> Command<'a> {
App::new(uucore::util_name()) Command::new(uucore::util_name())
.version(crate_version!()) .version(crate_version!())
.about(ABOUT) .about(ABOUT)
.override_usage(format_usage(USAGE)) .override_usage(format_usage(USAGE))
.setting(AppSettings::InferLongArgs) .infer_long_args(true)
.arg( .arg(
Arg::new(OPT_LOGICAL) Arg::new(OPT_LOGICAL)
.short('L') .short('L')

View file

@ -10,7 +10,7 @@
#[macro_use] #[macro_use]
extern crate uucore; extern crate uucore;
use clap::{crate_version, App, AppSettings, Arg}; use clap::{crate_version, Arg, Command};
use std::fs; use std::fs;
use std::io::{stdout, Write}; use std::io::{stdout, Write};
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
@ -95,12 +95,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
Ok(()) Ok(())
} }
pub fn uu_app<'a>() -> App<'a> { pub fn uu_app<'a>() -> Command<'a> {
App::new(uucore::util_name()) Command::new(uucore::util_name())
.version(crate_version!()) .version(crate_version!())
.about(ABOUT) .about(ABOUT)
.override_help(format_usage(USAGE)) .override_help(format_usage(USAGE))
.setting(AppSettings::InferLongArgs) .infer_long_args(true)
.arg( .arg(
Arg::new(OPT_CANONICALIZE) Arg::new(OPT_CANONICALIZE)
.short('f') .short('f')

View file

@ -10,7 +10,7 @@
#[macro_use] #[macro_use]
extern crate uucore; extern crate uucore;
use clap::{crate_version, App, AppSettings, Arg}; use clap::{crate_version, Arg, Command};
use std::{ use std::{
io::{stdout, Write}, io::{stdout, Write},
path::{Path, PathBuf}, path::{Path, PathBuf},
@ -70,12 +70,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
Ok(()) Ok(())
} }
pub fn uu_app<'a>() -> App<'a> { pub fn uu_app<'a>() -> Command<'a> {
App::new(uucore::util_name()) Command::new(uucore::util_name())
.version(crate_version!()) .version(crate_version!())
.about(ABOUT) .about(ABOUT)
.override_usage(format_usage(USAGE)) .override_usage(format_usage(USAGE))
.setting(AppSettings::InferLongArgs) .infer_long_args(true)
.arg( .arg(
Arg::new(OPT_QUIET) Arg::new(OPT_QUIET)
.short('q') .short('q')

View file

@ -7,7 +7,7 @@
// spell-checker:ignore (ToDO) subpath absto absfrom absbase // spell-checker:ignore (ToDO) subpath absto absfrom absbase
use clap::{crate_version, App, AppSettings, Arg}; use clap::{crate_version, Arg, Command};
use std::env; use std::env;
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use uucore::display::println_verbatim; use uucore::display::println_verbatim;
@ -78,12 +78,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
println_verbatim(result).map_err_context(String::new) println_verbatim(result).map_err_context(String::new)
} }
pub fn uu_app<'a>() -> App<'a> { pub fn uu_app<'a>() -> Command<'a> {
App::new(uucore::util_name()) Command::new(uucore::util_name())
.version(crate_version!()) .version(crate_version!())
.about(ABOUT) .about(ABOUT)
.override_usage(format_usage(USAGE)) .override_usage(format_usage(USAGE))
.setting(AppSettings::InferLongArgs) .infer_long_args(true)
.arg(Arg::new(options::DIR).short('d').takes_value(true).help( .arg(Arg::new(options::DIR).short('d').takes_value(true).help(
"If any of FROM and TO is not subpath of DIR, output absolute path instead of relative", "If any of FROM and TO is not subpath of DIR, output absolute path instead of relative",
)) ))

View file

@ -10,7 +10,7 @@
#[macro_use] #[macro_use]
extern crate uucore; extern crate uucore;
use clap::{crate_version, App, AppSettings, Arg}; use clap::{crate_version, Arg, Command};
use remove_dir_all::remove_dir_all; use remove_dir_all::remove_dir_all;
use std::collections::VecDeque; use std::collections::VecDeque;
use std::fs; use std::fs;
@ -139,12 +139,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
Ok(()) Ok(())
} }
pub fn uu_app<'a>() -> App<'a> { pub fn uu_app<'a>() -> Command<'a> {
App::new(uucore::util_name()) Command::new(uucore::util_name())
.version(crate_version!()) .version(crate_version!())
.about(ABOUT) .about(ABOUT)
.override_usage(format_usage(USAGE)) .override_usage(format_usage(USAGE))
.setting(AppSettings::InferLongArgs) .infer_long_args(true)
.arg( .arg(
Arg::new(OPT_FORCE) Arg::new(OPT_FORCE)
.short('f') .short('f')

View file

@ -10,7 +10,7 @@
#[macro_use] #[macro_use]
extern crate uucore; extern crate uucore;
use clap::{crate_version, App, AppSettings, Arg}; use clap::{crate_version, Arg, Command};
use std::fs::{read_dir, remove_dir}; use std::fs::{read_dir, remove_dir};
use std::io; use std::io;
use std::path::Path; use std::path::Path;
@ -170,12 +170,12 @@ struct Opts {
verbose: bool, verbose: bool,
} }
pub fn uu_app<'a>() -> App<'a> { pub fn uu_app<'a>() -> Command<'a> {
App::new(uucore::util_name()) Command::new(uucore::util_name())
.version(crate_version!()) .version(crate_version!())
.about(ABOUT) .about(ABOUT)
.override_usage(format_usage(USAGE)) .override_usage(format_usage(USAGE))
.setting(AppSettings::InferLongArgs) .infer_long_args(true)
.arg( .arg(
Arg::new(OPT_IGNORE_FAIL_NON_EMPTY) Arg::new(OPT_IGNORE_FAIL_NON_EMPTY)
.long(OPT_IGNORE_FAIL_NON_EMPTY) .long(OPT_IGNORE_FAIL_NON_EMPTY)

View file

@ -2,7 +2,7 @@
use uucore::error::{UResult, UUsageError}; use uucore::error::{UResult, UUsageError};
use clap::{App, AppSettings, Arg}; use clap::{Arg, Command};
use selinux::{OpaqueSecurityContext, SecurityClass, SecurityContext}; use selinux::{OpaqueSecurityContext, SecurityClass, SecurityContext};
use uucore::format_usage; use uucore::format_usage;
@ -48,7 +48,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
Ok(r) => r, Ok(r) => r,
Err(r) => { Err(r) => {
if let Error::CommandLine(ref r) = r { if let Error::CommandLine(ref r) = r {
match r.kind { match r.kind() {
clap::ErrorKind::DisplayHelp | clap::ErrorKind::DisplayVersion => { clap::ErrorKind::DisplayHelp | clap::ErrorKind::DisplayVersion => {
println!("{}", r); println!("{}", r);
return Ok(()); return Ok(());
@ -103,13 +103,13 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
} }
} }
pub fn uu_app<'a>() -> App<'a> { pub fn uu_app<'a>() -> Command<'a> {
App::new(uucore::util_name()) Command::new(uucore::util_name())
.version(VERSION) .version(VERSION)
.about(ABOUT) .about(ABOUT)
.after_help(DESCRIPTION) .after_help(DESCRIPTION)
.override_usage(format_usage(USAGE)) .override_usage(format_usage(USAGE))
.setting(AppSettings::InferLongArgs) .infer_long_args(true)
.arg( .arg(
Arg::new(options::COMPUTE) Arg::new(options::COMPUTE)
.short('c') .short('c')
@ -162,7 +162,7 @@ pub fn uu_app<'a>() -> App<'a> {
// //
// This is not how POSIX does things, but this is how the GNU implementation // This is not how POSIX does things, but this is how the GNU implementation
// parses its command line. // parses its command line.
.setting(clap::AppSettings::TrailingVarArg) .trailing_var_arg(true)
} }
#[derive(Debug)] #[derive(Debug)]
@ -205,7 +205,7 @@ struct Options {
arguments: Vec<OsString>, arguments: Vec<OsString>,
} }
fn parse_command_line(config: App, args: impl uucore::Args) -> Result<Options> { fn parse_command_line(config: Command, args: impl uucore::Args) -> Result<Options> {
let matches = config.try_get_matches_from(args)?; let matches = config.try_get_matches_from(args)?;
let compute_transition_context = matches.is_present(options::COMPUTE); let compute_transition_context = matches.is_present(options::COMPUTE);

View file

@ -7,7 +7,7 @@
use std::io::{stdout, ErrorKind, Write}; use std::io::{stdout, ErrorKind, Write};
use std::process::exit; use std::process::exit;
use clap::{crate_version, App, AppSettings, Arg}; use clap::{crate_version, Arg, Command};
use num_traits::Zero; use num_traits::Zero;
use uucore::error::FromIo; use uucore::error::FromIo;
@ -141,11 +141,11 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
} }
} }
pub fn uu_app<'a>() -> App<'a> { pub fn uu_app<'a>() -> Command<'a> {
App::new(uucore::util_name()) Command::new(uucore::util_name())
.setting(AppSettings::TrailingVarArg) .trailing_var_arg(true)
.setting(AppSettings::AllowNegativeNumbers) .allow_negative_numbers(true)
.setting(AppSettings::InferLongArgs) .infer_long_args(true)
.version(crate_version!()) .version(crate_version!())
.about(ABOUT) .about(ABOUT)
.override_usage(format_usage(USAGE)) .override_usage(format_usage(USAGE))

View file

@ -8,7 +8,7 @@
// spell-checker:ignore (words) writeback wipesync // spell-checker:ignore (words) writeback wipesync
use clap::{crate_version, App, AppSettings, Arg}; use clap::{crate_version, Arg, Command};
use rand::prelude::SliceRandom; use rand::prelude::SliceRandom;
use rand::Rng; use rand::Rng;
use std::cell::{Cell, RefCell}; use std::cell::{Cell, RefCell};
@ -314,13 +314,13 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
Ok(()) Ok(())
} }
pub fn uu_app<'a>() -> App<'a> { pub fn uu_app<'a>() -> Command<'a> {
App::new(uucore::util_name()) Command::new(uucore::util_name())
.version(crate_version!()) .version(crate_version!())
.about(ABOUT) .about(ABOUT)
.after_help(AFTER_HELP) .after_help(AFTER_HELP)
.override_usage(format_usage(USAGE)) .override_usage(format_usage(USAGE))
.setting(AppSettings::InferLongArgs) .infer_long_args(true)
.arg( .arg(
Arg::new(options::FORCE) Arg::new(options::FORCE)
.long(options::FORCE) .long(options::FORCE)

View file

@ -7,7 +7,7 @@
// spell-checker:ignore (ToDO) cmdline evec seps rvec fdata // spell-checker:ignore (ToDO) cmdline evec seps rvec fdata
use clap::{crate_version, App, AppSettings, Arg}; use clap::{crate_version, Arg, Command};
use rand::prelude::SliceRandom; use rand::prelude::SliceRandom;
use rand::RngCore; use rand::RngCore;
use std::fs::File; use std::fs::File;
@ -119,13 +119,13 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
Ok(()) Ok(())
} }
pub fn uu_app<'a>() -> App<'a> { pub fn uu_app<'a>() -> Command<'a> {
App::new(uucore::util_name()) Command::new(uucore::util_name())
.name(NAME) .name(NAME)
.about(ABOUT) .about(ABOUT)
.version(crate_version!()) .version(crate_version!())
.override_usage(format_usage(USAGE)) .override_usage(format_usage(USAGE))
.setting(AppSettings::InferLongArgs) .infer_long_args(true)
.arg( .arg(
Arg::new(options::ECHO) Arg::new(options::ECHO)
.short('e') .short('e')
@ -134,7 +134,7 @@ pub fn uu_app<'a>() -> App<'a> {
.value_name("ARG") .value_name("ARG")
.help("treat each ARG as an input line") .help("treat each ARG as an input line")
.multiple_occurrences(true) .multiple_occurrences(true)
.use_delimiter(false) .use_value_delimiter(false)
.min_values(0) .min_values(0)
.conflicts_with(options::INPUT_RANGE), .conflicts_with(options::INPUT_RANGE),
) )

View file

@ -13,7 +13,7 @@ use uucore::{
format_usage, format_usage,
}; };
use clap::{crate_version, App, AppSettings, Arg}; use clap::{crate_version, Arg, Command};
static ABOUT: &str = "Pause for NUMBER seconds."; static ABOUT: &str = "Pause for NUMBER seconds.";
const USAGE: &str = "\ const USAGE: &str = "\
@ -41,13 +41,13 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
Ok(()) Ok(())
} }
pub fn uu_app<'a>() -> App<'a> { pub fn uu_app<'a>() -> Command<'a> {
App::new(uucore::util_name()) Command::new(uucore::util_name())
.version(crate_version!()) .version(crate_version!())
.about(ABOUT) .about(ABOUT)
.after_help(LONG_HELP) .after_help(LONG_HELP)
.override_usage(format_usage(USAGE)) .override_usage(format_usage(USAGE))
.setting(AppSettings::InferLongArgs) .infer_long_args(true)
.arg( .arg(
Arg::new(options::NUMBER) Arg::new(options::NUMBER)
.help("pause for NUMBER seconds") .help("pause for NUMBER seconds")

View file

@ -25,7 +25,7 @@ mod numeric_str_cmp;
mod tmp_dir; mod tmp_dir;
use chunks::LineData; use chunks::LineData;
use clap::{crate_version, App, AppSettings, Arg}; use clap::{crate_version, Arg, Command};
use custom_str_cmp::custom_str_cmp; use custom_str_cmp::custom_str_cmp;
use ext_sort::ext_sort; use ext_sort::ext_sort;
use fnv::FnvHasher; use fnv::FnvHasher;
@ -1268,12 +1268,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
exec(&mut files, &settings, output, &mut tmp_dir) exec(&mut files, &settings, output, &mut tmp_dir)
} }
pub fn uu_app<'a>() -> App<'a> { pub fn uu_app<'a>() -> Command<'a> {
App::new(uucore::util_name()) Command::new(uucore::util_name())
.version(crate_version!()) .version(crate_version!())
.about(ABOUT) .about(ABOUT)
.override_usage(format_usage(USAGE)) .override_usage(format_usage(USAGE))
.setting(AppSettings::InferLongArgs) .infer_long_args(true)
.arg( .arg(
Arg::new(options::modes::SORT) Arg::new(options::modes::SORT)
.long(options::modes::SORT) .long(options::modes::SORT)

View file

@ -13,7 +13,7 @@ mod platform;
use crate::filenames::FilenameIterator; use crate::filenames::FilenameIterator;
use crate::filenames::SuffixType; use crate::filenames::SuffixType;
use clap::{crate_version, App, AppSettings, Arg, ArgMatches}; use clap::{crate_version, Arg, ArgMatches, Command};
use std::convert::TryInto; use std::convert::TryInto;
use std::env; use std::env;
use std::fmt; use std::fmt;
@ -62,13 +62,13 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
} }
} }
pub fn uu_app<'a>() -> App<'a> { pub fn uu_app<'a>() -> Command<'a> {
App::new(uucore::util_name()) Command::new(uucore::util_name())
.version(crate_version!()) .version(crate_version!())
.about("Create output files containing consecutive or interleaved sections of input") .about("Create output files containing consecutive or interleaved sections of input")
.after_help(AFTER_HELP) .after_help(AFTER_HELP)
.override_usage(format_usage(USAGE)) .override_usage(format_usage(USAGE))
.setting(AppSettings::InferLongArgs) .infer_long_args(true)
// strategy (mutually exclusive) // strategy (mutually exclusive)
.arg( .arg(
Arg::new(OPT_BYTES) Arg::new(OPT_BYTES)

View file

@ -16,7 +16,7 @@ use uucore::fsext::{
use uucore::libc::mode_t; use uucore::libc::mode_t;
use uucore::{entries, format_usage}; use uucore::{entries, format_usage};
use clap::{crate_version, App, AppSettings, Arg, ArgMatches}; use clap::{crate_version, Arg, ArgMatches, Command};
use std::borrow::Cow; use std::borrow::Cow;
use std::convert::AsRef; use std::convert::AsRef;
use std::os::unix::fs::{FileTypeExt, MetadataExt}; use std::os::unix::fs::{FileTypeExt, MetadataExt};
@ -967,12 +967,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
} }
} }
pub fn uu_app<'a>() -> App<'a> { pub fn uu_app<'a>() -> Command<'a> {
App::new(uucore::util_name()) Command::new(uucore::util_name())
.version(crate_version!()) .version(crate_version!())
.about(ABOUT) .about(ABOUT)
.override_usage(format_usage(USAGE)) .override_usage(format_usage(USAGE))
.setting(AppSettings::InferLongArgs) .infer_long_args(true)
.arg( .arg(
Arg::new(options::DEREFERENCE) Arg::new(options::DEREFERENCE)
.short('L') .short('L')

View file

@ -10,13 +10,13 @@
#[macro_use] #[macro_use]
extern crate uucore; extern crate uucore;
use clap::{crate_version, App, AppSettings, Arg, ArgMatches}; use clap::{crate_version, Arg, ArgMatches, Command};
use std::convert::{TryFrom, TryInto}; use std::convert::{TryFrom, TryInto};
use std::fs::File; use std::fs::File;
use std::io::{self, Write}; use std::io::{self, Write};
use std::os::unix::process::ExitStatusExt; use std::os::unix::process::ExitStatusExt;
use std::path::PathBuf; use std::path::PathBuf;
use std::process::Command; use std::process;
use tempfile::tempdir; use tempfile::tempdir;
use tempfile::TempDir; use tempfile::TempDir;
use uucore::error::{FromIo, UResult, USimpleError, UUsageError}; use uucore::error::{FromIo, UResult, USimpleError, UUsageError};
@ -131,7 +131,7 @@ fn check_option(matches: &ArgMatches, name: &str) -> Result<BufferType, ProgramO
} }
} }
fn set_command_env(command: &mut Command, buffer_name: &str, buffer_type: &BufferType) { fn set_command_env(command: &mut process::Command, buffer_name: &str, buffer_type: &BufferType) {
match buffer_type { match buffer_type {
BufferType::Size(m) => { BufferType::Size(m) => {
command.env(buffer_name, m.to_string()); command.env(buffer_name, m.to_string());
@ -164,7 +164,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
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))?;
let mut command_values = matches.values_of::<&str>(options::COMMAND).unwrap(); let mut command_values = matches.values_of::<&str>(options::COMMAND).unwrap();
let mut command = Command::new(command_values.next().unwrap()); let mut command = process::Command::new(command_values.next().unwrap());
let command_params: Vec<&str> = command_values.collect(); let command_params: Vec<&str> = command_values.collect();
let mut tmp_dir = tempdir().unwrap(); let mut tmp_dir = tempdir().unwrap();
@ -194,14 +194,14 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
} }
} }
pub fn uu_app<'a>() -> App<'a> { pub fn uu_app<'a>() -> Command<'a> {
App::new(uucore::util_name()) Command::new(uucore::util_name())
.version(crate_version!()) .version(crate_version!())
.about(ABOUT) .about(ABOUT)
.after_help(LONG_HELP) .after_help(LONG_HELP)
.override_usage(format_usage(USAGE)) .override_usage(format_usage(USAGE))
.setting(AppSettings::TrailingVarArg) .trailing_var_arg(true)
.setting(AppSettings::InferLongArgs) .infer_long_args(true)
.arg( .arg(
Arg::new(options::INPUT) Arg::new(options::INPUT)
.long(options::INPUT) .long(options::INPUT)

View file

@ -10,7 +10,7 @@
#[macro_use] #[macro_use]
extern crate uucore; extern crate uucore;
use clap::{crate_version, App, AppSettings, Arg}; use clap::{crate_version, Arg, Command};
use std::fs::File; use std::fs::File;
use std::io::{stdin, Read}; use std::io::{stdin, Read};
use std::path::Path; use std::path::Path;
@ -140,13 +140,13 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
Ok(()) Ok(())
} }
pub fn uu_app<'a>() -> App<'a> { pub fn uu_app<'a>() -> Command<'a> {
App::new(uucore::util_name()) Command::new(uucore::util_name())
.name(NAME) .name(NAME)
.version(crate_version!()) .version(crate_version!())
.override_usage(format_usage(USAGE)) .override_usage(format_usage(USAGE))
.about(SUMMARY) .about(SUMMARY)
.setting(AppSettings::InferLongArgs) .infer_long_args(true)
.arg( .arg(
Arg::new(options::FILE) Arg::new(options::FILE)
.multiple_occurrences(true) .multiple_occurrences(true)

View file

@ -9,7 +9,7 @@
extern crate libc; extern crate libc;
use clap::{crate_version, App, AppSettings, Arg}; use clap::{crate_version, Arg, Command};
use std::path::Path; use std::path::Path;
use uucore::display::Quotable; use uucore::display::Quotable;
use uucore::error::{UResult, USimpleError}; use uucore::error::{UResult, USimpleError};
@ -190,12 +190,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
Ok(()) Ok(())
} }
pub fn uu_app<'a>() -> App<'a> { pub fn uu_app<'a>() -> Command<'a> {
App::new(uucore::util_name()) Command::new(uucore::util_name())
.version(crate_version!()) .version(crate_version!())
.about(ABOUT) .about(ABOUT)
.override_usage(format_usage(USAGE)) .override_usage(format_usage(USAGE))
.setting(AppSettings::InferLongArgs) .infer_long_args(true)
.arg( .arg(
Arg::new(options::FILE_SYSTEM) Arg::new(options::FILE_SYSTEM)
.short('f') .short('f')

View file

@ -8,7 +8,7 @@
// spell-checker:ignore (ToDO) sbytes slen dlen memmem memmap Mmap mmap SIGBUS // spell-checker:ignore (ToDO) sbytes slen dlen memmem memmap Mmap mmap SIGBUS
mod error; mod error;
use clap::{crate_version, App, AppSettings, Arg}; use clap::{crate_version, Arg, Command};
use memchr::memmem; use memchr::memmem;
use memmap2::Mmap; use memmap2::Mmap;
use std::io::{stdin, stdout, BufWriter, Read, Write}; use std::io::{stdin, stdout, BufWriter, Read, Write};
@ -60,13 +60,13 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
tac(&files, before, regex, separator) tac(&files, before, regex, separator)
} }
pub fn uu_app<'a>() -> App<'a> { pub fn uu_app<'a>() -> Command<'a> {
App::new(uucore::util_name()) Command::new(uucore::util_name())
.name(NAME) .name(NAME)
.version(crate_version!()) .version(crate_version!())
.override_usage(format_usage(USAGE)) .override_usage(format_usage(USAGE))
.about(SUMMARY) .about(SUMMARY)
.setting(AppSettings::InferLongArgs) .infer_long_args(true)
.arg( .arg(
Arg::new(options::BEFORE) Arg::new(options::BEFORE)
.short('b') .short('b')

View file

@ -20,7 +20,7 @@ mod parse;
mod platform; mod platform;
use chunks::ReverseChunks; use chunks::ReverseChunks;
use clap::{App, AppSettings, Arg}; use clap::{Arg, Command};
use std::collections::VecDeque; use std::collections::VecDeque;
use std::convert::TryInto; use std::convert::TryInto;
use std::ffi::OsString; use std::ffi::OsString;
@ -275,12 +275,12 @@ fn arg_iterate<'a>(
} }
} }
pub fn uu_app<'a>() -> App<'a> { pub fn uu_app<'a>() -> Command<'a> {
App::new(uucore::util_name()) Command::new(uucore::util_name())
.version(crate_version!()) .version(crate_version!())
.about(ABOUT) .about(ABOUT)
.override_usage(format_usage(USAGE)) .override_usage(format_usage(USAGE))
.setting(AppSettings::InferLongArgs) .infer_long_args(true)
.arg( .arg(
Arg::new(options::BYTES) Arg::new(options::BYTES)
.short('c') .short('c')

View file

@ -8,7 +8,7 @@
#[macro_use] #[macro_use]
extern crate uucore; extern crate uucore;
use clap::{crate_version, App, AppSettings, Arg}; use clap::{crate_version, Arg, Command};
use retain_mut::RetainMut; use retain_mut::RetainMut;
use std::fs::OpenOptions; use std::fs::OpenOptions;
use std::io::{copy, sink, stdin, stdout, Error, ErrorKind, Read, Result, Write}; use std::io::{copy, sink, stdin, stdout, Error, ErrorKind, Read, Result, Write};
@ -55,13 +55,13 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
} }
} }
pub fn uu_app<'a>() -> App<'a> { pub fn uu_app<'a>() -> Command<'a> {
App::new(uucore::util_name()) Command::new(uucore::util_name())
.version(crate_version!()) .version(crate_version!())
.about(ABOUT) .about(ABOUT)
.override_usage(format_usage(USAGE)) .override_usage(format_usage(USAGE))
.after_help("If a FILE is -, it refers to a file named - .") .after_help("If a FILE is -, it refers to a file named - .")
.setting(AppSettings::InferLongArgs) .infer_long_args(true)
.arg( .arg(
Arg::new(options::APPEND) Arg::new(options::APPEND)
.long(options::APPEND) .long(options::APPEND)

View file

@ -10,7 +10,7 @@
mod parser; mod parser;
use clap::{crate_version, App}; use clap::{crate_version, Command};
use parser::{parse, Operator, Symbol, UnaryOperator}; use parser::{parse, Operator, Symbol, UnaryOperator};
use std::ffi::{OsStr, OsString}; use std::ffi::{OsStr, OsString};
use uucore::display::Quotable; use uucore::display::Quotable;
@ -90,8 +90,8 @@ for details about the options it supports.";
const ABOUT: &str = "Check file types and compare values."; const ABOUT: &str = "Check file types and compare values.";
pub fn uu_app<'a>() -> App<'a> { pub fn uu_app<'a>() -> Command<'a> {
App::new(uucore::util_name()) Command::new(uucore::util_name())
.version(crate_version!()) .version(crate_version!())
.about(ABOUT) .about(ABOUT)
.override_usage(format_usage(USAGE)) .override_usage(format_usage(USAGE))
@ -108,7 +108,7 @@ pub fn uumain(mut args: impl uucore::Args) -> UResult<()> {
// If invoked as [ we should recognize --help and --version (but not -h or -v) // If invoked as [ we should recognize --help and --version (but not -h or -v)
if args.len() == 1 && (args[0] == "--help" || args[0] == "--version") { if args.len() == 1 && (args[0] == "--help" || args[0] == "--version") {
// Let clap pretty-print help and version // Let clap pretty-print help and version
App::new(binary_name) Command::new(binary_name)
.version(crate_version!()) .version(crate_version!())
.about(ABOUT) .about(ABOUT)
.override_usage(format_usage(USAGE)) .override_usage(format_usage(USAGE))

View file

@ -14,9 +14,9 @@ extern crate uucore;
extern crate clap; extern crate clap;
use crate::status::ExitStatus; use crate::status::ExitStatus;
use clap::{crate_version, App, AppSettings, Arg}; use clap::{crate_version, Arg, Command};
use std::io::ErrorKind; use std::io::ErrorKind;
use std::process::{Child, Command, 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}; use uucore::error::{UResult, USimpleError};
@ -103,9 +103,9 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
.collect_str(InvalidEncodingHandling::ConvertLossy) .collect_str(InvalidEncodingHandling::ConvertLossy)
.accept_any(); .accept_any();
let app = uu_app(); let command = uu_app();
let matches = app.get_matches_from(args); let matches = command.get_matches_from(args);
let config = Config::from(&matches)?; let config = Config::from(&matches)?;
timeout( timeout(
@ -119,8 +119,8 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
) )
} }
pub fn uu_app<'a>() -> App<'a> { pub fn uu_app<'a>() -> Command<'a> {
App::new("timeout") Command::new("timeout")
.version(crate_version!()) .version(crate_version!())
.about(ABOUT) .about(ABOUT)
.override_usage(format_usage(USAGE)) .override_usage(format_usage(USAGE))
@ -162,8 +162,8 @@ pub fn uu_app<'a>() -> App<'a> {
.required(true) .required(true)
.multiple_occurrences(true) .multiple_occurrences(true)
) )
.setting(AppSettings::TrailingVarArg) .trailing_var_arg(true)
.setting(AppSettings::InferLongArgs) .infer_long_args(true)
} }
/// Remove pre-existing SIGCHLD handlers that would make waiting for the child's exit code fail. /// Remove pre-existing SIGCHLD handlers that would make waiting for the child's exit code fail.
@ -245,7 +245,7 @@ fn timeout(
if !foreground { if !foreground {
unsafe { libc::setpgid(0, 0) }; unsafe { libc::setpgid(0, 0) };
} }
let mut process = Command::new(&cmd[0]) let mut process = process::Command::new(&cmd[0])
.args(&cmd[1..]) .args(&cmd[1..])
.stdin(Stdio::inherit()) .stdin(Stdio::inherit())
.stdout(Stdio::inherit()) .stdout(Stdio::inherit())

View file

@ -13,7 +13,7 @@ pub extern crate filetime;
#[macro_use] #[macro_use]
extern crate uucore; extern crate uucore;
use clap::{crate_version, App, AppSettings, Arg, ArgGroup}; use clap::{crate_version, Arg, ArgGroup, Command};
use filetime::*; use filetime::*;
use std::fs::{self, File}; use std::fs::{self, File};
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
@ -149,12 +149,12 @@ Try 'touch --help' for more information."##,
Ok(()) Ok(())
} }
pub fn uu_app<'a>() -> App<'a> { pub fn uu_app<'a>() -> Command<'a> {
App::new(uucore::util_name()) Command::new(uucore::util_name())
.version(crate_version!()) .version(crate_version!())
.about(ABOUT) .about(ABOUT)
.override_usage(format_usage(USAGE)) .override_usage(format_usage(USAGE))
.setting(AppSettings::InferLongArgs) .infer_long_args(true)
.arg( .arg(
Arg::new(options::ACCESS) Arg::new(options::ACCESS)
.short('a') .short('a')

View file

@ -11,7 +11,7 @@ mod convert;
mod operation; mod operation;
mod unicode_table; mod unicode_table;
use clap::{crate_version, App, AppSettings, Arg}; use clap::{crate_version, Arg, Command};
use nom::AsBytes; use nom::AsBytes;
use operation::{translate_input, Sequence, SqueezeOperation, TranslateOperation}; use operation::{translate_input, Sequence, SqueezeOperation, TranslateOperation};
use std::io::{stdin, stdout, BufReader, BufWriter}; use std::io::{stdin, stdout, BufReader, BufWriter};
@ -137,13 +137,13 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
Ok(()) Ok(())
} }
pub fn uu_app<'a>() -> App<'a> { pub fn uu_app<'a>() -> Command<'a> {
App::new(uucore::util_name()) Command::new(uucore::util_name())
.version(crate_version!()) .version(crate_version!())
.about(ABOUT) .about(ABOUT)
.override_usage(format_usage(USAGE)) .override_usage(format_usage(USAGE))
.setting(AppSettings::InferLongArgs) .infer_long_args(true)
.setting(AppSettings::InferLongArgs) .infer_long_args(true)
.arg( .arg(
Arg::new(options::COMPLEMENT) Arg::new(options::COMPLEMENT)
.visible_short_alias('C') .visible_short_alias('C')

View file

@ -4,7 +4,7 @@
// * // *
// * For the full copyright and license information, please view the LICENSE // * For the full copyright and license information, please view the LICENSE
// * file that was distributed with this source code. // * file that was distributed with this source code.
use clap::{App, AppSettings, Arg}; use clap::{Arg, Command};
use std::io::Write; use std::io::Write;
use uucore::error::{set_exit_code, UResult}; use uucore::error::{set_exit_code, UResult};
@ -18,13 +18,13 @@ operation causes the program to return `1` instead.
#[uucore::main] #[uucore::main]
pub fn uumain(args: impl uucore::Args) -> UResult<()> { pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let mut app = uu_app(); let mut command = uu_app();
if let Ok(matches) = app.try_get_matches_from_mut(args) { if let Ok(matches) = command.try_get_matches_from_mut(args) {
let error = if matches.index_of("help").is_some() { let error = if matches.index_of("help").is_some() {
app.print_long_help() command.print_long_help()
} else if matches.index_of("version").is_some() { } else if matches.index_of("version").is_some() {
writeln!(std::io::stdout(), "{}", app.render_version()) writeln!(std::io::stdout(), "{}", command.render_version())
} else { } else {
Ok(()) Ok(())
}; };
@ -42,12 +42,13 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
Ok(()) Ok(())
} }
pub fn uu_app<'a>() -> App<'a> { pub fn uu_app<'a>() -> Command<'a> {
App::new(uucore::util_name()) Command::new(uucore::util_name())
.version(clap::crate_version!()) .version(clap::crate_version!())
.about(ABOUT) .about(ABOUT)
// We provide our own help and version options, to ensure maximum compatibility with GNU. // We provide our own help and version options, to ensure maximum compatibility with GNU.
.setting(AppSettings::DisableHelpFlag | AppSettings::DisableVersionFlag) .disable_help_flag(true)
.disable_version_flag(true)
.arg( .arg(
Arg::new("help") Arg::new("help")
.long("help") .long("help")

View file

@ -6,7 +6,7 @@
// * file that was distributed with this source code. // * file that was distributed with this source code.
// spell-checker:ignore (ToDO) RFILE refsize rfilename fsize tsize // spell-checker:ignore (ToDO) RFILE refsize rfilename fsize tsize
use clap::{crate_version, App, AppSettings, Arg}; use clap::{crate_version, Arg, Command};
use std::fs::{metadata, OpenOptions}; use std::fs::{metadata, OpenOptions};
use std::io::ErrorKind; use std::io::ErrorKind;
#[cfg(unix)] #[cfg(unix)]
@ -115,7 +115,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
.try_get_matches_from(args) .try_get_matches_from(args)
.map_err(|e| { .map_err(|e| {
e.print().expect("Error writing clap::Error"); e.print().expect("Error writing clap::Error");
match e.kind { match e.kind() {
clap::ErrorKind::DisplayHelp | clap::ErrorKind::DisplayVersion => 0, clap::ErrorKind::DisplayHelp | clap::ErrorKind::DisplayVersion => 0,
_ => 1, _ => 1,
} }
@ -137,12 +137,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
} }
} }
pub fn uu_app<'a>() -> App<'a> { pub fn uu_app<'a>() -> Command<'a> {
App::new(uucore::util_name()) Command::new(uucore::util_name())
.version(crate_version!()) .version(crate_version!())
.about(ABOUT) .about(ABOUT)
.override_usage(format_usage(USAGE)) .override_usage(format_usage(USAGE))
.setting(AppSettings::InferLongArgs) .infer_long_args(true)
.arg( .arg(
Arg::new(options::IO_BLOCKS) Arg::new(options::IO_BLOCKS)
.short('o') .short('o')

View file

@ -5,7 +5,7 @@
// * // *
// * For the full copyright and license information, please view the LICENSE // * For the full copyright and license information, please view the LICENSE
// * file that was distributed with this source code. // * file that was distributed with this source code.
use clap::{crate_version, App, AppSettings, Arg}; use clap::{crate_version, Arg, Command};
use std::collections::{HashMap, HashSet}; use std::collections::{HashMap, HashSet};
use std::fs::File; use std::fs::File;
use std::io::{stdin, BufRead, BufReader, Read}; use std::io::{stdin, BufRead, BufReader, Read};
@ -93,12 +93,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
Ok(()) Ok(())
} }
pub fn uu_app<'a>() -> App<'a> { pub fn uu_app<'a>() -> Command<'a> {
App::new(uucore::util_name()) Command::new(uucore::util_name())
.version(crate_version!()) .version(crate_version!())
.override_usage(format_usage(USAGE)) .override_usage(format_usage(USAGE))
.about(SUMMARY) .about(SUMMARY)
.setting(AppSettings::InferLongArgs) .infer_long_args(true)
.arg(Arg::new(options::FILE).default_value("-").hide(true)) .arg(Arg::new(options::FILE).default_value("-").hide(true))
} }

View file

@ -9,7 +9,7 @@
// spell-checker:ignore (ToDO) ttyname filedesc // spell-checker:ignore (ToDO) ttyname filedesc
use clap::{crate_version, App, AppSettings, Arg}; use clap::{crate_version, Arg, Command};
use std::ffi::CStr; use std::ffi::CStr;
use std::io::Write; use std::io::Write;
use uucore::error::{UResult, UUsageError}; use uucore::error::{UResult, UUsageError};
@ -66,12 +66,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
} }
} }
pub fn uu_app<'a>() -> App<'a> { pub fn uu_app<'a>() -> Command<'a> {
App::new(uucore::util_name()) Command::new(uucore::util_name())
.version(crate_version!()) .version(crate_version!())
.about(ABOUT) .about(ABOUT)
.override_usage(format_usage(USAGE)) .override_usage(format_usage(USAGE))
.setting(AppSettings::InferLongArgs) .infer_long_args(true)
.arg( .arg(
Arg::new(options::SILENT) Arg::new(options::SILENT)
.long(options::SILENT) .long(options::SILENT)

View file

@ -10,7 +10,7 @@
// spell-checker:ignore (ToDO) nodename kernelname kernelrelease kernelversion sysname hwplatform mnrsv // spell-checker:ignore (ToDO) nodename kernelname kernelrelease kernelversion sysname hwplatform mnrsv
use clap::{crate_version, App, AppSettings, Arg}; use clap::{crate_version, Arg, Command};
use platform_info::*; use platform_info::*;
use uucore::{ use uucore::{
error::{FromIo, UResult}, error::{FromIo, UResult},
@ -121,12 +121,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
Ok(()) Ok(())
} }
pub fn uu_app<'a>() -> App<'a> { pub fn uu_app<'a>() -> Command<'a> {
App::new(uucore::util_name()) Command::new(uucore::util_name())
.version(crate_version!()) .version(crate_version!())
.about(ABOUT) .about(ABOUT)
.override_usage(format_usage(USAGE)) .override_usage(format_usage(USAGE))
.setting(AppSettings::InferLongArgs) .infer_long_args(true)
.arg(Arg::new(options::ALL) .arg(Arg::new(options::ALL)
.short('a') .short('a')
.long(options::ALL) .long(options::ALL)

View file

@ -11,7 +11,7 @@
#[macro_use] #[macro_use]
extern crate uucore; extern crate uucore;
use clap::{crate_version, App, AppSettings, Arg}; use clap::{crate_version, Arg, Command};
use std::fs::File; use std::fs::File;
use std::io::{stdin, stdout, BufRead, BufReader, BufWriter, Read, Stdout, Write}; use std::io::{stdin, stdout, BufRead, BufReader, BufWriter, Read, Stdout, Write};
use std::str::from_utf8; use std::str::from_utf8;
@ -102,13 +102,13 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
unexpand(&Options::new(&matches)).map_err_context(String::new) unexpand(&Options::new(&matches)).map_err_context(String::new)
} }
pub fn uu_app<'a>() -> App<'a> { pub fn uu_app<'a>() -> Command<'a> {
App::new(uucore::util_name()) Command::new(uucore::util_name())
.name(NAME) .name(NAME)
.version(crate_version!()) .version(crate_version!())
.override_usage(format_usage(USAGE)) .override_usage(format_usage(USAGE))
.about(SUMMARY) .about(SUMMARY)
.setting(AppSettings::InferLongArgs) .infer_long_args(true)
.arg(Arg::new(options::FILE).hide(true).multiple_occurrences(true)) .arg(Arg::new(options::FILE).hide(true).multiple_occurrences(true))
.arg( .arg(
Arg::new(options::ALL) Arg::new(options::ALL)

View file

@ -5,7 +5,7 @@
// * For the full copyright and license information, please view the LICENSE // * For the full copyright and license information, please view the LICENSE
// * file that was distributed with this source code. // * file that was distributed with this source code.
use clap::{crate_version, App, AppSettings, Arg, ArgMatches}; use clap::{crate_version, Arg, ArgMatches, Command};
use std::fs::File; use std::fs::File;
use std::io::{self, stdin, stdout, BufRead, BufReader, BufWriter, Read, Write}; use std::io::{self, stdin, stdout, BufRead, BufReader, BufWriter, Read, Write};
use std::path::Path; use std::path::Path;
@ -290,12 +290,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
) )
} }
pub fn uu_app<'a>() -> App<'a> { pub fn uu_app<'a>() -> Command<'a> {
App::new(uucore::util_name()) Command::new(uucore::util_name())
.version(crate_version!()) .version(crate_version!())
.about(ABOUT) .about(ABOUT)
.override_usage(format_usage(USAGE)) .override_usage(format_usage(USAGE))
.setting(AppSettings::InferLongArgs) .infer_long_args(true)
.arg( .arg(
Arg::new(options::ALL_REPEATED) Arg::new(options::ALL_REPEATED)
.short('D') .short('D')

View file

@ -10,7 +10,7 @@
use std::fs::remove_file; use std::fs::remove_file;
use std::path::Path; use std::path::Path;
use clap::{crate_version, App, AppSettings, Arg}; use clap::{crate_version, Arg, Command};
use uucore::display::Quotable; use uucore::display::Quotable;
use uucore::error::{FromIo, UResult}; use uucore::error::{FromIo, UResult};
@ -27,11 +27,11 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
remove_file(path).map_err_context(|| format!("cannot unlink {}", path.quote())) remove_file(path).map_err_context(|| format!("cannot unlink {}", path.quote()))
} }
pub fn uu_app<'a>() -> App<'a> { pub fn uu_app<'a>() -> Command<'a> {
App::new(uucore::util_name()) Command::new(uucore::util_name())
.version(crate_version!()) .version(crate_version!())
.about(ABOUT) .about(ABOUT)
.setting(AppSettings::InferLongArgs) .infer_long_args(true)
.arg( .arg(
Arg::new(OPT_PATH) Arg::new(OPT_PATH)
.required(true) .required(true)

View file

@ -9,7 +9,7 @@
// spell-checker:ignore (ToDO) getloadavg upsecs updays nusers loadavg boottime uphours upmins // spell-checker:ignore (ToDO) getloadavg upsecs updays nusers loadavg boottime uphours upmins
use chrono::{Local, TimeZone, Utc}; use chrono::{Local, TimeZone, Utc};
use clap::{crate_version, App, AppSettings, Arg}; use clap::{crate_version, Arg, Command};
use uucore::format_usage; use uucore::format_usage;
// import crate time from utmpx // import crate time from utmpx
@ -59,12 +59,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
} }
} }
pub fn uu_app<'a>() -> App<'a> { pub fn uu_app<'a>() -> Command<'a> {
App::new(uucore::util_name()) Command::new(uucore::util_name())
.version(crate_version!()) .version(crate_version!())
.about(ABOUT) .about(ABOUT)
.override_usage(format_usage(USAGE)) .override_usage(format_usage(USAGE))
.setting(AppSettings::InferLongArgs) .infer_long_args(true)
.arg( .arg(
Arg::new(options::SINCE) Arg::new(options::SINCE)
.short('s') .short('s')

View file

@ -10,7 +10,7 @@
use std::path::Path; use std::path::Path;
use clap::{crate_version, App, AppSettings, Arg}; use clap::{crate_version, Arg, Command};
use uucore::error::UResult; use uucore::error::UResult;
use uucore::format_usage; use uucore::format_usage;
use uucore::utmpx::{self, Utmpx}; use uucore::utmpx::{self, Utmpx};
@ -58,11 +58,11 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
Ok(()) Ok(())
} }
pub fn uu_app<'a>() -> App<'a> { pub fn uu_app<'a>() -> Command<'a> {
App::new(uucore::util_name()) Command::new(uucore::util_name())
.version(crate_version!()) .version(crate_version!())
.about(ABOUT) .about(ABOUT)
.override_usage(format_usage(USAGE)) .override_usage(format_usage(USAGE))
.setting(AppSettings::InferLongArgs) .infer_long_args(true)
.arg(Arg::new(ARG_FILES).takes_value(true).max_values(1)) .arg(Arg::new(ARG_FILES).takes_value(true).max_values(1))
} }

View file

@ -18,7 +18,7 @@ use utf8::{BufReadDecoder, BufReadDecoderError};
use uucore::format_usage; use uucore::format_usage;
use word_count::{TitledWordCount, WordCount}; use word_count::{TitledWordCount, WordCount};
use clap::{crate_version, App, AppSettings, Arg, ArgMatches}; use clap::{crate_version, Arg, ArgMatches, Command};
use std::cmp::max; use std::cmp::max;
use std::error::Error; use std::error::Error;
@ -183,12 +183,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
wc(&inputs, &settings) wc(&inputs, &settings)
} }
pub fn uu_app<'a>() -> App<'a> { pub fn uu_app<'a>() -> Command<'a> {
App::new(uucore::util_name()) Command::new(uucore::util_name())
.version(crate_version!()) .version(crate_version!())
.about(ABOUT) .about(ABOUT)
.override_usage(format_usage(USAGE)) .override_usage(format_usage(USAGE))
.setting(AppSettings::InferLongArgs) .infer_long_args(true)
.arg( .arg(
Arg::new(options::BYTES) Arg::new(options::BYTES)
.short('c') .short('c')

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