mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-27 19:17:43 +00:00
refactor/uucore ~ make util_name and execution_phrase functions
Since util_name and execution_phrase no longer rely on features that are only available to macros, they may as well be plain functions.
This commit is contained in:
parent
5f2335829a
commit
252220e9eb
100 changed files with 279 additions and 297 deletions
|
@ -27,7 +27,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uu_app() -> App<'static, 'static> {
|
pub fn uu_app() -> App<'static, 'static> {
|
||||||
App::new(util_name!())
|
App::new(uucore::util_name())
|
||||||
.version(crate_version!())
|
.version(crate_version!())
|
||||||
.about(ABOUT)
|
.about(ABOUT)
|
||||||
.after_help(SUMMARY)
|
.after_help(SUMMARY)
|
||||||
|
|
|
@ -29,13 +29,13 @@ static VERSION: &str = env!("CARGO_PKG_VERSION");
|
||||||
static BASE_CMD_PARSE_ERROR: i32 = 1;
|
static BASE_CMD_PARSE_ERROR: i32 = 1;
|
||||||
|
|
||||||
fn usage() -> String {
|
fn usage() -> String {
|
||||||
format!("{0} [OPTION]... [FILE]", execution_phrase!())
|
format!("{0} [OPTION]... [FILE]", uucore::execution_phrase())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uumain(args: impl uucore::Args) -> i32 {
|
pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
let format = Format::Base32;
|
let format = Format::Base32;
|
||||||
let usage = usage();
|
let usage = usage();
|
||||||
let name = util_name!();
|
let name = uucore::util_name();
|
||||||
|
|
||||||
let config_result: Result<base_common::Config, String> =
|
let config_result: Result<base_common::Config, String> =
|
||||||
base_common::parse_base_cmd_args(args, &name, VERSION, ABOUT, &usage);
|
base_common::parse_base_cmd_args(args, &name, VERSION, ABOUT, &usage);
|
||||||
|
@ -59,5 +59,5 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uu_app() -> App<'static, 'static> {
|
pub fn uu_app() -> App<'static, 'static> {
|
||||||
base_common::base_app(&util_name!(), VERSION, ABOUT)
|
base_common::base_app(&uucore::util_name(), VERSION, ABOUT)
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,13 +30,13 @@ static VERSION: &str = env!("CARGO_PKG_VERSION");
|
||||||
static BASE_CMD_PARSE_ERROR: i32 = 1;
|
static BASE_CMD_PARSE_ERROR: i32 = 1;
|
||||||
|
|
||||||
fn usage() -> String {
|
fn usage() -> String {
|
||||||
format!("{0} [OPTION]... [FILE]", execution_phrase!())
|
format!("{0} [OPTION]... [FILE]", uucore::execution_phrase())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uumain(args: impl uucore::Args) -> i32 {
|
pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
let format = Format::Base64;
|
let format = Format::Base64;
|
||||||
let usage = usage();
|
let usage = usage();
|
||||||
let name = util_name!();
|
let name = uucore::util_name();
|
||||||
let config_result: Result<base_common::Config, String> =
|
let config_result: Result<base_common::Config, String> =
|
||||||
base_common::parse_base_cmd_args(args, &name, VERSION, ABOUT, &usage);
|
base_common::parse_base_cmd_args(args, &name, VERSION, ABOUT, &usage);
|
||||||
let config = config_result.unwrap_or_else(|s| crash!(BASE_CMD_PARSE_ERROR, "{}", s));
|
let config = config_result.unwrap_or_else(|s| crash!(BASE_CMD_PARSE_ERROR, "{}", s));
|
||||||
|
|
|
@ -21,7 +21,7 @@ fn usage() -> String {
|
||||||
format!(
|
format!(
|
||||||
"{0} NAME [SUFFIX]
|
"{0} NAME [SUFFIX]
|
||||||
{0} OPTION... NAME...",
|
{0} OPTION... NAME...",
|
||||||
execution_phrase!()
|
uucore::execution_phrase()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
crash!(
|
crash!(
|
||||||
1,
|
1,
|
||||||
"{1}\nTry '{0} --help' for more information.",
|
"{1}\nTry '{0} --help' for more information.",
|
||||||
execution_phrase!(),
|
uucore::execution_phrase(),
|
||||||
"missing operand"
|
"missing operand"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
crash!(
|
crash!(
|
||||||
1,
|
1,
|
||||||
"extra operand '{1}'\nTry '{0} --help' for more information.",
|
"extra operand '{1}'\nTry '{0} --help' for more information.",
|
||||||
execution_phrase!(),
|
uucore::execution_phrase(),
|
||||||
matches.values_of(options::NAME).unwrap().nth(2).unwrap()
|
matches.values_of(options::NAME).unwrap().nth(2).unwrap()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -93,7 +93,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uu_app() -> App<'static, 'static> {
|
pub fn uu_app() -> App<'static, 'static> {
|
||||||
App::new(util_name!())
|
App::new(uucore::util_name())
|
||||||
.version(crate_version!())
|
.version(crate_version!())
|
||||||
.about(SUMMARY)
|
.about(SUMMARY)
|
||||||
.arg(
|
.arg(
|
||||||
|
|
|
@ -43,11 +43,11 @@ const ENCODINGS: &[(&str, Format)] = &[
|
||||||
];
|
];
|
||||||
|
|
||||||
fn usage() -> String {
|
fn usage() -> String {
|
||||||
format!("{0} [OPTION]... [FILE]", execution_phrase!())
|
format!("{0} [OPTION]... [FILE]", uucore::execution_phrase())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uu_app() -> App<'static, 'static> {
|
pub fn uu_app() -> App<'static, 'static> {
|
||||||
let mut app = base_common::base_app(&util_name!(), crate_version!(), ABOUT);
|
let mut app = base_common::base_app(&uucore::util_name(), crate_version!(), ABOUT);
|
||||||
for encoding in ENCODINGS {
|
for encoding in ENCODINGS {
|
||||||
app = app.arg(Arg::with_name(encoding.0).long(encoding.0));
|
app = app.arg(Arg::with_name(encoding.0).long(encoding.0));
|
||||||
}
|
}
|
||||||
|
@ -75,7 +75,7 @@ fn parse_cmd_args(args: impl uucore::Args) -> (Config, Format) {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uumain(args: impl uucore::Args) -> i32 {
|
pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
let name = util_name!();
|
let name = uucore::util_name();
|
||||||
let (config, format) = parse_cmd_args(args);
|
let (config, format) = parse_cmd_args(args);
|
||||||
// Create a reference to stdin so we can return a locked stdin from
|
// Create a reference to stdin so we can return a locked stdin from
|
||||||
// parse_base_cmd_args
|
// parse_base_cmd_args
|
||||||
|
|
|
@ -234,7 +234,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uu_app() -> App<'static, 'static> {
|
pub fn uu_app() -> App<'static, 'static> {
|
||||||
App::new(util_name!())
|
App::new(uucore::util_name())
|
||||||
.name(NAME)
|
.name(NAME)
|
||||||
.version(crate_version!())
|
.version(crate_version!())
|
||||||
.usage(SYNTAX)
|
.usage(SYNTAX)
|
||||||
|
@ -396,7 +396,7 @@ fn cat_files(files: Vec<String>, options: &OutputOptions) -> UResult<()> {
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
// each next line is expected to display "cat: …"
|
// each next line is expected to display "cat: …"
|
||||||
let line_joiner = format!("\n{}: ", util_name!());
|
let line_joiner = format!("\n{}: ", uucore::util_name());
|
||||||
|
|
||||||
Err(uucore::error::USimpleError::new(
|
Err(uucore::error::USimpleError::new(
|
||||||
error_messages.len() as i32,
|
error_messages.len() as i32,
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
#![allow(clippy::upper_case_acronyms)]
|
#![allow(clippy::upper_case_acronyms)]
|
||||||
|
|
||||||
use uucore::{execution_phrase, show_error, show_usage_error, show_warning, util_name};
|
use uucore::{show_error, show_usage_error, show_warning};
|
||||||
|
|
||||||
use clap::{App, Arg};
|
use clap::{App, Arg};
|
||||||
use selinux::{OpaqueSecurityContext, SecurityContext};
|
use selinux::{OpaqueSecurityContext, SecurityContext};
|
||||||
|
@ -56,7 +56,7 @@ fn get_usage() -> String {
|
||||||
"{0} [OPTION]... CONTEXT FILE... \n \
|
"{0} [OPTION]... CONTEXT FILE... \n \
|
||||||
{0} [OPTION]... [-u USER] [-r ROLE] [-l RANGE] [-t TYPE] FILE... \n \
|
{0} [OPTION]... [-u USER] [-r ROLE] [-l RANGE] [-t TYPE] FILE... \n \
|
||||||
{0} [OPTION]... --reference=RFILE FILE...",
|
{0} [OPTION]... --reference=RFILE FILE...",
|
||||||
execution_phrase!()
|
uucore::execution_phrase()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,7 +152,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uu_app() -> App<'static, 'static> {
|
pub fn uu_app() -> App<'static, 'static> {
|
||||||
App::new(util_name!())
|
App::new(uucore::util_name())
|
||||||
.version(VERSION)
|
.version(VERSION)
|
||||||
.about(ABOUT)
|
.about(ABOUT)
|
||||||
.arg(
|
.arg(
|
||||||
|
@ -563,7 +563,7 @@ fn process_file(
|
||||||
if options.verbose {
|
if options.verbose {
|
||||||
println!(
|
println!(
|
||||||
"{}: Changing security context of: {}",
|
"{}: Changing security context of: {}",
|
||||||
util_name!(),
|
uucore::util_name(),
|
||||||
file_full_name.to_string_lossy()
|
file_full_name.to_string_lossy()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,7 +62,7 @@ const FTS_LOGICAL: u8 = 1 << 2;
|
||||||
fn usage() -> String {
|
fn usage() -> String {
|
||||||
format!(
|
format!(
|
||||||
"{0} [OPTION]... GROUP FILE...\n {0} [OPTION]... --reference=RFILE FILE...",
|
"{0} [OPTION]... GROUP FILE...\n {0} [OPTION]... --reference=RFILE FILE...",
|
||||||
execution_phrase!()
|
uucore::execution_phrase()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -197,7 +197,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uu_app() -> App<'static, 'static> {
|
pub fn uu_app() -> App<'static, 'static> {
|
||||||
App::new(util_name!())
|
App::new(uucore::util_name())
|
||||||
.version(VERSION)
|
.version(VERSION)
|
||||||
.about(ABOUT)
|
.about(ABOUT)
|
||||||
.arg(
|
.arg(
|
||||||
|
|
|
@ -41,7 +41,7 @@ fn usage() -> String {
|
||||||
"{0} [OPTION]... MODE[,MODE]... FILE...
|
"{0} [OPTION]... MODE[,MODE]... FILE...
|
||||||
or: {0} [OPTION]... OCTAL-MODE FILE...
|
or: {0} [OPTION]... OCTAL-MODE FILE...
|
||||||
or: {0} [OPTION]... --reference=RFILE FILE...",
|
or: {0} [OPTION]... --reference=RFILE FILE...",
|
||||||
execution_phrase!()
|
uucore::execution_phrase()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,7 +116,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uu_app() -> App<'static, 'static> {
|
pub fn uu_app() -> App<'static, 'static> {
|
||||||
App::new(util_name!())
|
App::new(uucore::util_name())
|
||||||
.version(crate_version!())
|
.version(crate_version!())
|
||||||
.about(ABOUT)
|
.about(ABOUT)
|
||||||
.arg(
|
.arg(
|
||||||
|
|
|
@ -64,7 +64,7 @@ const FTS_LOGICAL: u8 = 1 << 2;
|
||||||
fn usage() -> String {
|
fn usage() -> String {
|
||||||
format!(
|
format!(
|
||||||
"{0} [OPTION]... [OWNER][:[GROUP]] FILE...\n{0} [OPTION]... --reference=RFILE FILE...",
|
"{0} [OPTION]... [OWNER][:[GROUP]] FILE...\n{0} [OPTION]... --reference=RFILE FILE...",
|
||||||
execution_phrase!()
|
uucore::execution_phrase()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -165,7 +165,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uu_app() -> App<'static, 'static> {
|
pub fn uu_app() -> App<'static, 'static> {
|
||||||
App::new(util_name!())
|
App::new(uucore::util_name())
|
||||||
.version(crate_version!())
|
.version(crate_version!())
|
||||||
.about(ABOUT)
|
.about(ABOUT)
|
||||||
.arg(
|
.arg(
|
||||||
|
|
|
@ -16,7 +16,7 @@ use std::io::Error;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
use uucore::libc::{self, chroot, setgid, setgroups, setuid};
|
use uucore::libc::{self, chroot, setgid, setgroups, setuid};
|
||||||
use uucore::{entries, execution_phrase, InvalidEncodingHandling};
|
use uucore::{entries, InvalidEncodingHandling};
|
||||||
|
|
||||||
static ABOUT: &str = "Run COMMAND with root directory set to NEWROOT.";
|
static ABOUT: &str = "Run COMMAND with root directory set to NEWROOT.";
|
||||||
static SYNTAX: &str = "[OPTION]... NEWROOT [COMMAND [ARG]...]";
|
static SYNTAX: &str = "[OPTION]... NEWROOT [COMMAND [ARG]...]";
|
||||||
|
@ -46,7 +46,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
None => crash!(
|
None => crash!(
|
||||||
1,
|
1,
|
||||||
"Missing operand: NEWROOT\nTry '{} --help' for more information.",
|
"Missing operand: NEWROOT\nTry '{} --help' for more information.",
|
||||||
execution_phrase!()
|
uucore::execution_phrase()
|
||||||
),
|
),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uu_app() -> App<'static, 'static> {
|
pub fn uu_app() -> App<'static, 'static> {
|
||||||
App::new(util_name!())
|
App::new(uucore::util_name())
|
||||||
.version(crate_version!())
|
.version(crate_version!())
|
||||||
.about(ABOUT)
|
.about(ABOUT)
|
||||||
.usage(SYNTAX)
|
.usage(SYNTAX)
|
||||||
|
|
|
@ -213,7 +213,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uu_app() -> App<'static, 'static> {
|
pub fn uu_app() -> App<'static, 'static> {
|
||||||
App::new(util_name!())
|
App::new(uucore::util_name())
|
||||||
.name(NAME)
|
.name(NAME)
|
||||||
.version(crate_version!())
|
.version(crate_version!())
|
||||||
.about(SUMMARY)
|
.about(SUMMARY)
|
||||||
|
|
|
@ -7,9 +7,6 @@
|
||||||
|
|
||||||
// spell-checker:ignore (ToDO) delim mkdelim
|
// spell-checker:ignore (ToDO) delim mkdelim
|
||||||
|
|
||||||
#[macro_use]
|
|
||||||
extern crate uucore;
|
|
||||||
|
|
||||||
use std::cmp::Ordering;
|
use std::cmp::Ordering;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::{self, stdin, BufRead, BufReader, Stdin};
|
use std::io::{self, stdin, BufRead, BufReader, Stdin};
|
||||||
|
@ -32,7 +29,7 @@ mod options {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn usage() -> String {
|
fn usage() -> String {
|
||||||
format!("{} [OPTION]... FILE1 FILE2", execution_phrase!())
|
format!("{} [OPTION]... FILE1 FILE2", uucore::execution_phrase())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn mkdelim(col: usize, opts: &ArgMatches) -> String {
|
fn mkdelim(col: usize, opts: &ArgMatches) -> String {
|
||||||
|
@ -148,7 +145,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uu_app() -> App<'static, 'static> {
|
pub fn uu_app() -> App<'static, 'static> {
|
||||||
App::new(util_name!())
|
App::new(uucore::util_name())
|
||||||
.version(crate_version!())
|
.version(crate_version!())
|
||||||
.about(ABOUT)
|
.about(ABOUT)
|
||||||
.after_help(LONG_HELP)
|
.after_help(LONG_HELP)
|
||||||
|
|
|
@ -99,7 +99,7 @@ quick_error! {
|
||||||
NotImplemented(opt: String) { display("Option '{}' not yet implemented.", opt) }
|
NotImplemented(opt: String) { display("Option '{}' not yet implemented.", opt) }
|
||||||
|
|
||||||
/// Invalid arguments to backup
|
/// Invalid arguments to backup
|
||||||
Backup(description: String) { display("{}\nTry '{} --help' for more information.", description, execution_phrase!()) }
|
Backup(description: String) { display("{}\nTry '{} --help' for more information.", description, uucore::execution_phrase()) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -223,7 +223,7 @@ fn usage() -> String {
|
||||||
"{0} [OPTION]... [-T] SOURCE DEST
|
"{0} [OPTION]... [-T] SOURCE DEST
|
||||||
{0} [OPTION]... SOURCE... DIRECTORY
|
{0} [OPTION]... SOURCE... DIRECTORY
|
||||||
{0} [OPTION]... -t DIRECTORY SOURCE...",
|
{0} [OPTION]... -t DIRECTORY SOURCE...",
|
||||||
execution_phrase!()
|
uucore::execution_phrase()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -293,7 +293,7 @@ static DEFAULT_ATTRIBUTES: &[Attribute] = &[
|
||||||
];
|
];
|
||||||
|
|
||||||
pub fn uu_app() -> App<'static, 'static> {
|
pub fn uu_app() -> App<'static, 'static> {
|
||||||
App::new(util_name!())
|
App::new(uucore::util_name())
|
||||||
.version(crate_version!())
|
.version(crate_version!())
|
||||||
.about(ABOUT)
|
.about(ABOUT)
|
||||||
.arg(Arg::with_name(options::TARGET_DIRECTORY)
|
.arg(Arg::with_name(options::TARGET_DIRECTORY)
|
||||||
|
@ -1060,7 +1060,7 @@ impl OverwriteMode {
|
||||||
match *self {
|
match *self {
|
||||||
OverwriteMode::NoClobber => Err(Error::NotAllFilesCopied),
|
OverwriteMode::NoClobber => Err(Error::NotAllFilesCopied),
|
||||||
OverwriteMode::Interactive(_) => {
|
OverwriteMode::Interactive(_) => {
|
||||||
if prompt_yes!("{}: overwrite {}? ", util_name!(), path.display()) {
|
if prompt_yes!("{}: overwrite {}? ", uucore::util_name(), path.display()) {
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
Err(Error::Skipped(format!(
|
Err(Error::Skipped(format!(
|
||||||
|
|
|
@ -35,7 +35,10 @@ mod options {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn usage() -> String {
|
fn usage() -> String {
|
||||||
format!("{0} [OPTION]... FILE PATTERN...", execution_phrase!())
|
format!(
|
||||||
|
"{0} [OPTION]... FILE PATTERN...",
|
||||||
|
uucore::execution_phrase()
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Command line options for csplit.
|
/// Command line options for csplit.
|
||||||
|
@ -739,7 +742,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uu_app() -> App<'static, 'static> {
|
pub fn uu_app() -> App<'static, 'static> {
|
||||||
App::new(util_name!())
|
App::new(uucore::util_name())
|
||||||
.version(crate_version!())
|
.version(crate_version!())
|
||||||
.about(SUMMARY)
|
.about(SUMMARY)
|
||||||
.arg(
|
.arg(
|
||||||
|
|
|
@ -548,7 +548,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uu_app() -> App<'static, 'static> {
|
pub fn uu_app() -> App<'static, 'static> {
|
||||||
App::new(util_name!())
|
App::new(uucore::util_name())
|
||||||
.name(NAME)
|
.name(NAME)
|
||||||
.version(crate_version!())
|
.version(crate_version!())
|
||||||
.usage(SYNTAX)
|
.usage(SYNTAX)
|
||||||
|
|
|
@ -8,9 +8,6 @@
|
||||||
|
|
||||||
// spell-checker:ignore (chrono) Datelike Timelike ; (format) DATEFILE MMDDhhmm ; (vars) datetime datetimes
|
// spell-checker:ignore (chrono) Datelike Timelike ; (format) DATEFILE MMDDhhmm ; (vars) datetime datetimes
|
||||||
|
|
||||||
#[macro_use]
|
|
||||||
extern crate uucore;
|
|
||||||
|
|
||||||
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};
|
||||||
|
@ -253,7 +250,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uu_app() -> App<'static, 'static> {
|
pub fn uu_app() -> App<'static, 'static> {
|
||||||
App::new(util_name!())
|
App::new(uucore::util_name())
|
||||||
.version(crate_version!())
|
.version(crate_version!())
|
||||||
.about(ABOUT)
|
.about(ABOUT)
|
||||||
.arg(
|
.arg(
|
||||||
|
|
|
@ -7,8 +7,6 @@
|
||||||
|
|
||||||
// spell-checker:ignore fname, tname, fpath, specfile, testfile, unspec, ifile, ofile, outfile, fullblock, urand, fileio, atoe, atoibm, behaviour, bmax, bremain, btotal, cflags, creat, ctable, ctty, datastructures, doesnt, etoa, fileout, fname, gnudd, iconvflags, nocache, noctty, noerror, nofollow, nolinks, nonblock, oconvflags, outfile, parseargs, rlen, rmax, rposition, rremain, rsofar, rstat, sigusr, sigval, wlen, wstat
|
// spell-checker:ignore fname, tname, fpath, specfile, testfile, unspec, ifile, ofile, outfile, fullblock, urand, fileio, atoe, atoibm, behaviour, bmax, bremain, btotal, cflags, creat, ctable, ctty, datastructures, doesnt, etoa, fileout, fname, gnudd, iconvflags, nocache, noctty, noerror, nofollow, nolinks, nonblock, oconvflags, outfile, parseargs, rlen, rmax, rposition, rremain, rsofar, rstat, sigusr, sigval, wlen, wstat
|
||||||
|
|
||||||
#[macro_use]
|
|
||||||
extern crate uucore;
|
|
||||||
use uucore::InvalidEncodingHandling;
|
use uucore::InvalidEncodingHandling;
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -1046,7 +1044,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uu_app() -> clap::App<'static, 'static> {
|
pub fn uu_app() -> clap::App<'static, 'static> {
|
||||||
clap::App::new(util_name!())
|
clap::App::new(uucore::util_name())
|
||||||
.version(crate_version!())
|
.version(crate_version!())
|
||||||
.about(ABOUT)
|
.about(ABOUT)
|
||||||
.arg(
|
.arg(
|
||||||
|
|
|
@ -80,7 +80,7 @@ struct Filesystem {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn usage() -> String {
|
fn usage() -> String {
|
||||||
format!("{0} [OPTION]... [FILE]...", execution_phrase!())
|
format!("{0} [OPTION]... [FILE]...", uucore::execution_phrase())
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FsSelector {
|
impl FsSelector {
|
||||||
|
@ -295,7 +295,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
{
|
{
|
||||||
if matches.is_present(OPT_INODES) {
|
if matches.is_present(OPT_INODES) {
|
||||||
println!("{}: doesn't support -i option", util_name!());
|
println!("{}: doesn't support -i option", uucore::util_name());
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -427,7 +427,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uu_app() -> App<'static, 'static> {
|
pub fn uu_app() -> App<'static, 'static> {
|
||||||
App::new(util_name!())
|
App::new(uucore::util_name())
|
||||||
.version(crate_version!())
|
.version(crate_version!())
|
||||||
.about(ABOUT)
|
.about(ABOUT)
|
||||||
.arg(
|
.arg(
|
||||||
|
|
|
@ -63,7 +63,7 @@ pub fn guess_syntax() -> OutputFmt {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn usage() -> String {
|
fn usage() -> String {
|
||||||
format!("{0} {1}", execution_phrase!(), SYNTAX)
|
format!("{0} {1}", uucore::execution_phrase(), SYNTAX)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uumain(args: impl uucore::Args) -> i32 {
|
pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
|
@ -153,7 +153,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uu_app() -> App<'static, 'static> {
|
pub fn uu_app() -> App<'static, 'static> {
|
||||||
App::new(util_name!())
|
App::new(uucore::util_name())
|
||||||
.version(crate_version!())
|
.version(crate_version!())
|
||||||
.about(SUMMARY)
|
.about(SUMMARY)
|
||||||
.after_help(LONG_HELP)
|
.after_help(LONG_HELP)
|
||||||
|
|
|
@ -21,7 +21,7 @@ mod options {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn usage() -> String {
|
fn usage() -> String {
|
||||||
format!("{0} [OPTION] NAME...", execution_phrase!())
|
format!("{0} [OPTION] NAME...", uucore::execution_phrase())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_long_usage() -> String {
|
fn get_long_usage() -> String {
|
||||||
|
@ -86,7 +86,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uu_app() -> App<'static, 'static> {
|
pub fn uu_app() -> App<'static, 'static> {
|
||||||
App::new(util_name!())
|
App::new(uucore::util_name())
|
||||||
.about(ABOUT)
|
.about(ABOUT)
|
||||||
.version(crate_version!())
|
.version(crate_version!())
|
||||||
.arg(
|
.arg(
|
||||||
|
|
|
@ -396,7 +396,7 @@ fn usage() -> String {
|
||||||
format!(
|
format!(
|
||||||
"{0} [OPTION]... [FILE]...
|
"{0} [OPTION]... [FILE]...
|
||||||
{0} [OPTION]... --files0-from=F",
|
{0} [OPTION]... --files0-from=F",
|
||||||
execution_phrase!()
|
uucore::execution_phrase()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -424,7 +424,7 @@ Valid arguments are:
|
||||||
- 'iso'
|
- 'iso'
|
||||||
Try '{} --help' for more information.",
|
Try '{} --help' for more information.",
|
||||||
s,
|
s,
|
||||||
execution_phrase!()
|
uucore::execution_phrase()
|
||||||
),
|
),
|
||||||
DuError::InvalidTimeArg(s) => write!(
|
DuError::InvalidTimeArg(s) => write!(
|
||||||
f,
|
f,
|
||||||
|
@ -466,7 +466,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
|
|
||||||
let options = Options {
|
let options = Options {
|
||||||
all: matches.is_present(options::ALL),
|
all: matches.is_present(options::ALL),
|
||||||
util_name: util_name!(),
|
util_name: uucore::util_name(),
|
||||||
max_depth,
|
max_depth,
|
||||||
total: matches.is_present(options::TOTAL),
|
total: matches.is_present(options::TOTAL),
|
||||||
separate_dirs: matches.is_present(options::SEPARATE_DIRS),
|
separate_dirs: matches.is_present(options::SEPARATE_DIRS),
|
||||||
|
@ -625,7 +625,7 @@ fn parse_depth(max_depth_str: Option<&str>, summarize: bool) -> UResult<Option<u
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uu_app() -> App<'static, 'static> {
|
pub fn uu_app() -> App<'static, 'static> {
|
||||||
App::new(util_name!())
|
App::new(uucore::util_name())
|
||||||
.version(crate_version!())
|
.version(crate_version!())
|
||||||
.about(SUMMARY)
|
.about(SUMMARY)
|
||||||
.after_help(LONG_HELP)
|
.after_help(LONG_HELP)
|
||||||
|
|
|
@ -132,7 +132,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uu_app() -> App<'static, 'static> {
|
pub fn uu_app() -> App<'static, 'static> {
|
||||||
App::new(util_name!())
|
App::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.
|
||||||
|
|
|
@ -33,7 +33,7 @@ static LONG_HELP: &str = "";
|
||||||
static DEFAULT_TABSTOP: usize = 8;
|
static DEFAULT_TABSTOP: usize = 8;
|
||||||
|
|
||||||
fn usage() -> String {
|
fn usage() -> String {
|
||||||
format!("{0} [OPTION]... [FILE]...", execution_phrase!())
|
format!("{0} [OPTION]... [FILE]...", uucore::execution_phrase())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The mode to use when replacing tabs beyond the last one specified in
|
/// The mode to use when replacing tabs beyond the last one specified in
|
||||||
|
@ -178,7 +178,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uu_app() -> App<'static, 'static> {
|
pub fn uu_app() -> App<'static, 'static> {
|
||||||
App::new(util_name!())
|
App::new(uucore::util_name())
|
||||||
.version(crate_version!())
|
.version(crate_version!())
|
||||||
.about(ABOUT)
|
.about(ABOUT)
|
||||||
.after_help(LONG_HELP)
|
.after_help(LONG_HELP)
|
||||||
|
|
|
@ -18,7 +18,7 @@ const VERSION: &str = "version";
|
||||||
const HELP: &str = "help";
|
const HELP: &str = "help";
|
||||||
|
|
||||||
pub fn uu_app() -> App<'static, 'static> {
|
pub fn uu_app() -> App<'static, 'static> {
|
||||||
App::new(util_name!())
|
App::new(uucore::util_name())
|
||||||
.arg(Arg::with_name(VERSION).long(VERSION))
|
.arg(Arg::with_name(VERSION).long(VERSION))
|
||||||
.arg(Arg::with_name(HELP).long(HELP))
|
.arg(Arg::with_name(HELP).long(HELP))
|
||||||
}
|
}
|
||||||
|
@ -140,5 +140,5 @@ Environment variables:
|
||||||
}
|
}
|
||||||
|
|
||||||
fn print_version() {
|
fn print_version() {
|
||||||
println!("{} {}", util_name!(), crate_version!());
|
println!("{} {}", uucore::util_name(), crate_version!());
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,7 +75,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uu_app() -> App<'static, 'static> {
|
pub fn uu_app() -> App<'static, 'static> {
|
||||||
App::new(util_name!())
|
App::new(uucore::util_name())
|
||||||
.version(crate_version!())
|
.version(crate_version!())
|
||||||
.about(SUMMARY)
|
.about(SUMMARY)
|
||||||
.arg(Arg::with_name(options::NUMBER).multiple(true))
|
.arg(Arg::with_name(options::NUMBER).multiple(true))
|
||||||
|
|
|
@ -10,7 +10,6 @@ extern crate uucore;
|
||||||
|
|
||||||
use clap::App;
|
use clap::App;
|
||||||
use uucore::error::UResult;
|
use uucore::error::UResult;
|
||||||
use uucore::util_name;
|
|
||||||
|
|
||||||
#[uucore_procs::gen_uumain]
|
#[uucore_procs::gen_uumain]
|
||||||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
|
@ -19,5 +18,5 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uu_app() -> App<'static, 'static> {
|
pub fn uu_app() -> App<'static, 'static> {
|
||||||
App::new(util_name!())
|
App::new(uucore::util_name())
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,7 @@ static OPT_TAB_WIDTH: &str = "tab-width";
|
||||||
static ARG_FILES: &str = "files";
|
static ARG_FILES: &str = "files";
|
||||||
|
|
||||||
fn usage() -> String {
|
fn usage() -> String {
|
||||||
format!("{} [OPTION]... [FILE]...", execution_phrase!())
|
format!("{} [OPTION]... [FILE]...", uucore::execution_phrase())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type FileOrStdReader = BufReader<Box<dyn Read + 'static>>;
|
pub type FileOrStdReader = BufReader<Box<dyn Read + 'static>>;
|
||||||
|
@ -211,7 +211,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uu_app() -> App<'static, 'static> {
|
pub fn uu_app() -> App<'static, 'static> {
|
||||||
App::new(util_name!())
|
App::new(uucore::util_name())
|
||||||
.version(crate_version!())
|
.version(crate_version!())
|
||||||
.about(ABOUT)
|
.about(ABOUT)
|
||||||
.arg(
|
.arg(
|
||||||
|
|
|
@ -64,7 +64,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uu_app() -> App<'static, 'static> {
|
pub fn uu_app() -> App<'static, 'static> {
|
||||||
App::new(util_name!())
|
App::new(uucore::util_name())
|
||||||
.name(NAME)
|
.name(NAME)
|
||||||
.version(crate_version!())
|
.version(crate_version!())
|
||||||
.usage(SYNTAX)
|
.usage(SYNTAX)
|
||||||
|
|
|
@ -29,7 +29,7 @@ static ABOUT: &str = "Print group memberships for each USERNAME or, \
|
||||||
(which may differ if the groups data‐base has changed).";
|
(which may differ if the groups data‐base has changed).";
|
||||||
|
|
||||||
fn usage() -> String {
|
fn usage() -> String {
|
||||||
format!("{0} [OPTION]... [USERNAME]...", execution_phrase!())
|
format!("{0} [OPTION]... [USERNAME]...", uucore::execution_phrase())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uumain(args: impl uucore::Args) -> i32 {
|
pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
|
@ -85,7 +85,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uu_app() -> App<'static, 'static> {
|
pub fn uu_app() -> App<'static, 'static> {
|
||||||
App::new(util_name!())
|
App::new(uucore::util_name())
|
||||||
.version(crate_version!())
|
.version(crate_version!())
|
||||||
.about(ABOUT)
|
.about(ABOUT)
|
||||||
.arg(
|
.arg(
|
||||||
|
|
|
@ -342,7 +342,7 @@ pub fn uu_app_common() -> App<'static, 'static> {
|
||||||
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(util_name!())
|
App::new(uucore::util_name())
|
||||||
.version(crate_version!())
|
.version(crate_version!())
|
||||||
.about("Compute and check message digests.")
|
.about("Compute and check message digests.")
|
||||||
.arg(
|
.arg(
|
||||||
|
|
|
@ -9,7 +9,7 @@ use clap::{crate_version, App, Arg};
|
||||||
use std::convert::TryFrom;
|
use std::convert::TryFrom;
|
||||||
use std::ffi::OsString;
|
use std::ffi::OsString;
|
||||||
use std::io::{self, ErrorKind, Read, Seek, SeekFrom, Write};
|
use std::io::{self, ErrorKind, Read, Seek, SeekFrom, Write};
|
||||||
use uucore::{crash, show_error_custom_description, util_name};
|
use uucore::{crash, show_error_custom_description};
|
||||||
|
|
||||||
const EXIT_FAILURE: i32 = 1;
|
const EXIT_FAILURE: i32 = 1;
|
||||||
const EXIT_SUCCESS: i32 = 0;
|
const EXIT_SUCCESS: i32 = 0;
|
||||||
|
@ -41,7 +41,7 @@ use lines::zlines;
|
||||||
use take::take_all_but;
|
use take::take_all_but;
|
||||||
|
|
||||||
pub fn uu_app() -> App<'static, 'static> {
|
pub fn uu_app() -> App<'static, 'static> {
|
||||||
App::new(util_name!())
|
App::new(uucore::util_name())
|
||||||
.version(crate_version!())
|
.version(crate_version!())
|
||||||
.about(ABOUT)
|
.about(ABOUT)
|
||||||
.usage(USAGE)
|
.usage(USAGE)
|
||||||
|
|
|
@ -29,7 +29,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uu_app() -> App<'static, 'static> {
|
pub fn uu_app() -> App<'static, 'static> {
|
||||||
App::new(util_name!())
|
App::new(uucore::util_name())
|
||||||
.version(crate_version!())
|
.version(crate_version!())
|
||||||
.usage(SYNTAX)
|
.usage(SYNTAX)
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,7 +54,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn usage() -> String {
|
fn usage() -> String {
|
||||||
format!("{0} [OPTION]... [HOSTNAME]", execution_phrase!())
|
format!("{0} [OPTION]... [HOSTNAME]", uucore::execution_phrase())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn execute(args: impl uucore::Args) -> UResult<()> {
|
fn execute(args: impl uucore::Args) -> UResult<()> {
|
||||||
|
@ -74,7 +74,7 @@ fn execute(args: impl uucore::Args) -> UResult<()> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uu_app() -> App<'static, 'static> {
|
pub fn uu_app() -> App<'static, 'static> {
|
||||||
App::new(util_name!())
|
App::new(uucore::util_name())
|
||||||
.version(crate_version!())
|
.version(crate_version!())
|
||||||
.about(ABOUT)
|
.about(ABOUT)
|
||||||
.arg(
|
.arg(
|
||||||
|
|
|
@ -77,7 +77,7 @@ mod options {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn usage() -> String {
|
fn usage() -> String {
|
||||||
format!("{0} [OPTION]... [USER]...", execution_phrase!())
|
format!("{0} [OPTION]... [USER]...", uucore::execution_phrase())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_description() -> String {
|
fn get_description() -> String {
|
||||||
|
@ -347,7 +347,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uu_app() -> App<'static, 'static> {
|
pub fn uu_app() -> App<'static, 'static> {
|
||||||
App::new(util_name!())
|
App::new(uucore::util_name())
|
||||||
.version(crate_version!())
|
.version(crate_version!())
|
||||||
.about(ABOUT)
|
.about(ABOUT)
|
||||||
.arg(
|
.arg(
|
||||||
|
|
|
@ -86,11 +86,13 @@ impl Display for InstallError {
|
||||||
use InstallError as IE;
|
use InstallError as IE;
|
||||||
match self {
|
match self {
|
||||||
IE::Unimplemented(opt) => write!(f, "Unimplemented feature: {}", opt),
|
IE::Unimplemented(opt) => write!(f, "Unimplemented feature: {}", opt),
|
||||||
IE::DirNeedsArg() => write!(
|
IE::DirNeedsArg() => {
|
||||||
|
write!(
|
||||||
f,
|
f,
|
||||||
"{} with -d requires at least one argument.",
|
"{} with -d requires at least one argument.",
|
||||||
util_name!()
|
uucore::util_name()
|
||||||
),
|
)
|
||||||
|
}
|
||||||
IE::CreateDirFailed(dir, e) => {
|
IE::CreateDirFailed(dir, e) => {
|
||||||
Display::fmt(&uio_error!(e, "failed to create {}", dir.display()), f)
|
Display::fmt(&uio_error!(e, "failed to create {}", dir.display()), f)
|
||||||
}
|
}
|
||||||
|
@ -173,7 +175,7 @@ static OPT_CONTEXT: &str = "context";
|
||||||
static ARG_FILES: &str = "files";
|
static ARG_FILES: &str = "files";
|
||||||
|
|
||||||
fn usage() -> String {
|
fn usage() -> String {
|
||||||
format!("{0} [OPTION]... [FILE]...", execution_phrase!())
|
format!("{0} [OPTION]... [FILE]...", uucore::execution_phrase())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Main install utility function, called from main.rs.
|
/// Main install utility function, called from main.rs.
|
||||||
|
@ -202,7 +204,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uu_app() -> App<'static, 'static> {
|
pub fn uu_app() -> App<'static, 'static> {
|
||||||
App::new(util_name!())
|
App::new(uucore::util_name())
|
||||||
.version(crate_version!())
|
.version(crate_version!())
|
||||||
.about(ABOUT)
|
.about(ABOUT)
|
||||||
.arg(
|
.arg(
|
||||||
|
|
|
@ -41,7 +41,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
.accept_any();
|
.accept_any();
|
||||||
let (args, obs_signal) = handle_obsolete(args);
|
let (args, obs_signal) = handle_obsolete(args);
|
||||||
|
|
||||||
let usage = format!("{} [OPTIONS]... PID...", execution_phrase!());
|
let usage = format!("{} [OPTIONS]... PID...", uucore::execution_phrase());
|
||||||
let matches = uu_app().usage(&usage[..]).get_matches_from(args);
|
let matches = uu_app().usage(&usage[..]).get_matches_from(args);
|
||||||
|
|
||||||
let mode = if matches.is_present(options::TABLE) || matches.is_present(options::TABLE_OLD) {
|
let mode = if matches.is_present(options::TABLE) || matches.is_present(options::TABLE_OLD) {
|
||||||
|
@ -76,7 +76,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uu_app() -> App<'static, 'static> {
|
pub fn uu_app() -> App<'static, 'static> {
|
||||||
App::new(util_name!())
|
App::new(uucore::util_name())
|
||||||
.version(crate_version!())
|
.version(crate_version!())
|
||||||
.about(ABOUT)
|
.about(ABOUT)
|
||||||
.arg(
|
.arg(
|
||||||
|
|
|
@ -20,7 +20,7 @@ pub mod options {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn usage() -> String {
|
fn usage() -> String {
|
||||||
format!("{0} FILE1 FILE2", execution_phrase!())
|
format!("{0} FILE1 FILE2", uucore::execution_phrase())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn normalize_error_message(e: Error) -> String {
|
pub fn normalize_error_message(e: Error) -> String {
|
||||||
|
@ -51,7 +51,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uu_app() -> App<'static, 'static> {
|
pub fn uu_app() -> App<'static, 'static> {
|
||||||
App::new(util_name!())
|
App::new(uucore::util_name())
|
||||||
.version(crate_version!())
|
.version(crate_version!())
|
||||||
.about(ABOUT)
|
.about(ABOUT)
|
||||||
.arg(
|
.arg(
|
||||||
|
|
|
@ -70,7 +70,7 @@ impl Display for LnError {
|
||||||
f,
|
f,
|
||||||
"extra operand '{}'\nTry '{} --help' for more information.",
|
"extra operand '{}'\nTry '{} --help' for more information.",
|
||||||
s,
|
s,
|
||||||
execution_phrase!()
|
uucore::execution_phrase()
|
||||||
),
|
),
|
||||||
Self::InvalidBackupMode(s) => write!(f, "{}", s),
|
Self::InvalidBackupMode(s) => write!(f, "{}", s),
|
||||||
}
|
}
|
||||||
|
@ -98,7 +98,7 @@ fn usage() -> String {
|
||||||
{0} [OPTION]... TARGET (2nd form)
|
{0} [OPTION]... TARGET (2nd form)
|
||||||
{0} [OPTION]... TARGET... DIRECTORY (3rd form)
|
{0} [OPTION]... TARGET... DIRECTORY (3rd form)
|
||||||
{0} [OPTION]... -t DIRECTORY TARGET... (4th form)",
|
{0} [OPTION]... -t DIRECTORY TARGET... (4th form)",
|
||||||
execution_phrase!()
|
uucore::execution_phrase()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -196,7 +196,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uu_app() -> App<'static, 'static> {
|
pub fn uu_app() -> App<'static, 'static> {
|
||||||
App::new(util_name!())
|
App::new(uucore::util_name())
|
||||||
.version(crate_version!())
|
.version(crate_version!())
|
||||||
.about(ABOUT)
|
.about(ABOUT)
|
||||||
.arg(
|
.arg(
|
||||||
|
@ -431,7 +431,7 @@ fn link(src: &Path, dst: &Path, settings: &Settings) -> Result<()> {
|
||||||
match settings.overwrite {
|
match settings.overwrite {
|
||||||
OverwriteMode::NoClobber => {}
|
OverwriteMode::NoClobber => {}
|
||||||
OverwriteMode::Interactive => {
|
OverwriteMode::Interactive => {
|
||||||
print!("{}: overwrite '{}'? ", util_name!(), dst.display());
|
print!("{}: overwrite '{}'? ", uucore::util_name(), dst.display());
|
||||||
if !read_yes() {
|
if !read_yes() {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ fn get_userlogin() -> Option<String> {
|
||||||
static SUMMARY: &str = "Print user's login name";
|
static SUMMARY: &str = "Print user's login name";
|
||||||
|
|
||||||
fn usage() -> String {
|
fn usage() -> String {
|
||||||
execution_phrase!()
|
uucore::execution_phrase()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uumain(args: impl uucore::Args) -> i32 {
|
pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
|
@ -56,7 +56,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uu_app() -> App<'static, 'static> {
|
pub fn uu_app() -> App<'static, 'static> {
|
||||||
App::new(util_name!())
|
App::new(uucore::util_name())
|
||||||
.version(crate_version!())
|
.version(crate_version!())
|
||||||
.about(SUMMARY)
|
.about(SUMMARY)
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,7 @@ use uucore::libc::{S_IXGRP, S_IXOTH, S_IXUSR};
|
||||||
use uucore::{fs::display_permissions, version_cmp::version_cmp};
|
use uucore::{fs::display_permissions, version_cmp::version_cmp};
|
||||||
|
|
||||||
fn usage() -> String {
|
fn usage() -> String {
|
||||||
format!("{0} [OPTION]... [FILE]...", execution_phrase!())
|
format!("{0} [OPTION]... [FILE]...", uucore::execution_phrase())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub mod options {
|
pub mod options {
|
||||||
|
@ -618,7 +618,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uu_app() -> App<'static, 'static> {
|
pub fn uu_app() -> App<'static, 'static> {
|
||||||
App::new(util_name!())
|
App::new(uucore::util_name())
|
||||||
.version(crate_version!())
|
.version(crate_version!())
|
||||||
.about(
|
.about(
|
||||||
"By default, ls will list the files and contents of any directories on \
|
"By default, ls will list the files and contents of any directories on \
|
||||||
|
|
|
@ -23,7 +23,7 @@ mod options {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn usage() -> String {
|
fn usage() -> String {
|
||||||
format!("{0} [OPTION]... [USER]", execution_phrase!())
|
format!("{0} [OPTION]... [USER]", uucore::execution_phrase())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[uucore_procs::gen_uumain]
|
#[uucore_procs::gen_uumain]
|
||||||
|
@ -51,7 +51,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uu_app() -> App<'static, 'static> {
|
pub fn uu_app() -> App<'static, 'static> {
|
||||||
App::new(util_name!())
|
App::new(uucore::util_name())
|
||||||
.version(crate_version!())
|
.version(crate_version!())
|
||||||
.about(ABOUT)
|
.about(ABOUT)
|
||||||
.arg(
|
.arg(
|
||||||
|
@ -103,7 +103,11 @@ fn mkdir(path: &Path, recursive: bool, mode: u16, verbose: bool) -> UResult<()>
|
||||||
create_dir(path).map_err_context(|| format!("cannot create directory '{}'", path.display()))?;
|
create_dir(path).map_err_context(|| format!("cannot create directory '{}'", path.display()))?;
|
||||||
|
|
||||||
if verbose {
|
if verbose {
|
||||||
println!("{}: created directory '{}'", util_name!(), path.display());
|
println!(
|
||||||
|
"{}: created directory '{}'",
|
||||||
|
uucore::util_name(),
|
||||||
|
path.display()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
chmod(path, mode)
|
chmod(path, mode)
|
||||||
|
|
|
@ -70,7 +70,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uu_app() -> App<'static, 'static> {
|
pub fn uu_app() -> App<'static, 'static> {
|
||||||
App::new(util_name!())
|
App::new(uucore::util_name())
|
||||||
.name(NAME)
|
.name(NAME)
|
||||||
.version(crate_version!())
|
.version(crate_version!())
|
||||||
.usage(USAGE)
|
.usage(USAGE)
|
||||||
|
|
|
@ -71,8 +71,8 @@ fn _mknod(file_name: &str, mode: mode_t, dev: dev_t) -> i32 {
|
||||||
}
|
}
|
||||||
|
|
||||||
if errno == -1 {
|
if errno == -1 {
|
||||||
let c_str =
|
let c_str = CString::new(uucore::execution_phrase().as_bytes())
|
||||||
CString::new(execution_phrase!().as_bytes()).expect("Failed to convert to CString");
|
.expect("Failed to convert to CString");
|
||||||
// shows the error from the mknod syscall
|
// shows the error from the mknod syscall
|
||||||
libc::perror(c_str.as_ptr());
|
libc::perror(c_str.as_ptr());
|
||||||
}
|
}
|
||||||
|
@ -113,7 +113,10 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
if ch == 'p' {
|
if ch == 'p' {
|
||||||
if matches.is_present("major") || matches.is_present("minor") {
|
if matches.is_present("major") || matches.is_present("minor") {
|
||||||
eprintln!("Fifos do not have major and minor device numbers.");
|
eprintln!("Fifos do not have major and minor device numbers.");
|
||||||
eprintln!("Try '{} --help' for more information.", execution_phrase!());
|
eprintln!(
|
||||||
|
"Try '{} --help' for more information.",
|
||||||
|
uucore::execution_phrase()
|
||||||
|
);
|
||||||
1
|
1
|
||||||
} else {
|
} else {
|
||||||
_mknod(file_name, S_IFIFO | mode, 0)
|
_mknod(file_name, S_IFIFO | mode, 0)
|
||||||
|
@ -122,7 +125,10 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
match (matches.value_of("major"), matches.value_of("minor")) {
|
match (matches.value_of("major"), matches.value_of("minor")) {
|
||||||
(None, None) | (_, None) | (None, _) => {
|
(None, None) | (_, None) | (None, _) => {
|
||||||
eprintln!("Special files require major and minor device numbers.");
|
eprintln!("Special files require major and minor device numbers.");
|
||||||
eprintln!("Try '{} --help' for more information.", execution_phrase!());
|
eprintln!(
|
||||||
|
"Try '{} --help' for more information.",
|
||||||
|
uucore::execution_phrase()
|
||||||
|
);
|
||||||
1
|
1
|
||||||
}
|
}
|
||||||
(Some(major), Some(minor)) => {
|
(Some(major), Some(minor)) => {
|
||||||
|
@ -145,7 +151,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uu_app() -> App<'static, 'static> {
|
pub fn uu_app() -> App<'static, 'static> {
|
||||||
App::new(util_name!())
|
App::new(uucore::util_name())
|
||||||
.version(crate_version!())
|
.version(crate_version!())
|
||||||
.usage(USAGE)
|
.usage(USAGE)
|
||||||
.after_help(LONG_HELP)
|
.after_help(LONG_HELP)
|
||||||
|
|
|
@ -37,7 +37,7 @@ static OPT_T: &str = "t";
|
||||||
static ARG_TEMPLATE: &str = "template";
|
static ARG_TEMPLATE: &str = "template";
|
||||||
|
|
||||||
fn usage() -> String {
|
fn usage() -> String {
|
||||||
format!("{0} [OPTION]... [TEMPLATE]", execution_phrase!())
|
format!("{0} [OPTION]... [TEMPLATE]", uucore::execution_phrase())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
@ -134,7 +134,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uu_app() -> App<'static, 'static> {
|
pub fn uu_app() -> App<'static, 'static> {
|
||||||
App::new(util_name!())
|
App::new(uucore::util_name())
|
||||||
.version(crate_version!())
|
.version(crate_version!())
|
||||||
.about(ABOUT)
|
.about(ABOUT)
|
||||||
.arg(
|
.arg(
|
||||||
|
|
|
@ -93,7 +93,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uu_app() -> App<'static, 'static> {
|
pub fn uu_app() -> App<'static, 'static> {
|
||||||
App::new(util_name!())
|
App::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!())
|
||||||
.arg(
|
.arg(
|
||||||
|
|
|
@ -63,7 +63,7 @@ fn usage() -> String {
|
||||||
"{0} [OPTION]... [-T] SOURCE DEST
|
"{0} [OPTION]... [-T] SOURCE DEST
|
||||||
{0} [OPTION]... SOURCE... DIRECTORY
|
{0} [OPTION]... SOURCE... DIRECTORY
|
||||||
{0} [OPTION]... -t DIRECTORY SOURCE...",
|
{0} [OPTION]... -t DIRECTORY SOURCE...",
|
||||||
execution_phrase!()
|
uucore::execution_phrase()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,7 +133,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uu_app() -> App<'static, 'static> {
|
pub fn uu_app() -> App<'static, 'static> {
|
||||||
App::new(util_name!())
|
App::new(uucore::util_name())
|
||||||
.version(crate_version!())
|
.version(crate_version!())
|
||||||
.about(ABOUT)
|
.about(ABOUT)
|
||||||
.arg(
|
.arg(
|
||||||
|
@ -296,7 +296,7 @@ fn exec(files: &[PathBuf], b: Behavior) -> i32 {
|
||||||
"mv: extra operand '{}'\n\
|
"mv: extra operand '{}'\n\
|
||||||
Try '{} --help' for more information.",
|
Try '{} --help' for more information.",
|
||||||
files[2].display(),
|
files[2].display(),
|
||||||
execution_phrase!()
|
uucore::execution_phrase()
|
||||||
);
|
);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -353,7 +353,7 @@ fn rename(from: &Path, to: &Path, b: &Behavior) -> io::Result<()> {
|
||||||
match b.overwrite {
|
match b.overwrite {
|
||||||
OverwriteMode::NoClobber => return Ok(()),
|
OverwriteMode::NoClobber => return Ok(()),
|
||||||
OverwriteMode::Interactive => {
|
OverwriteMode::Interactive => {
|
||||||
println!("{}: overwrite '{}'? ", util_name!(), to.display());
|
println!("{}: overwrite '{}'? ", uucore::util_name(), to.display());
|
||||||
if !read_yes() {
|
if !read_yes() {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ Run COMMAND with an adjusted niceness, which affects process scheduling.
|
||||||
With no COMMAND, print the current niceness. Niceness values range from at
|
With no COMMAND, print the current niceness. Niceness values range from at
|
||||||
least -20 (most favorable to the process) to 19 (least favorable to the
|
least -20 (most favorable to the process) to 19 (least favorable to the
|
||||||
process).",
|
process).",
|
||||||
execution_phrase!()
|
uucore::execution_phrase()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
if !matches.is_present(options::COMMAND) {
|
if !matches.is_present(options::COMMAND) {
|
||||||
show_error!(
|
show_error!(
|
||||||
"A command must be given with an adjustment.\nTry '{} --help' for more information.",
|
"A command must be given with an adjustment.\nTry '{} --help' for more information.",
|
||||||
execution_phrase!()
|
uucore::execution_phrase()
|
||||||
);
|
);
|
||||||
return 125;
|
return 125;
|
||||||
}
|
}
|
||||||
|
@ -101,7 +101,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uu_app() -> App<'static, 'static> {
|
pub fn uu_app() -> App<'static, 'static> {
|
||||||
App::new(util_name!())
|
App::new(uucore::util_name())
|
||||||
.setting(AppSettings::TrailingVarArg)
|
.setting(AppSettings::TrailingVarArg)
|
||||||
.version(crate_version!())
|
.version(crate_version!())
|
||||||
.arg(
|
.arg(
|
||||||
|
|
|
@ -143,7 +143,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uu_app() -> App<'static, 'static> {
|
pub fn uu_app() -> App<'static, 'static> {
|
||||||
App::new(util_name!())
|
App::new(uucore::util_name())
|
||||||
.name(NAME)
|
.name(NAME)
|
||||||
.version(crate_version!())
|
.version(crate_version!())
|
||||||
.usage(USAGE)
|
.usage(USAGE)
|
||||||
|
|
|
@ -71,7 +71,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uu_app() -> App<'static, 'static> {
|
pub fn uu_app() -> App<'static, 'static> {
|
||||||
App::new(util_name!())
|
App::new(uucore::util_name())
|
||||||
.version(crate_version!())
|
.version(crate_version!())
|
||||||
.about(ABOUT)
|
.about(ABOUT)
|
||||||
.after_help(LONG_HELP)
|
.after_help(LONG_HELP)
|
||||||
|
@ -157,7 +157,10 @@ fn find_stdout() -> File {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn usage() -> String {
|
fn usage() -> String {
|
||||||
format!("{0} COMMAND [ARG]...\n {0} FLAG", execution_phrase!())
|
format!(
|
||||||
|
"{0} COMMAND [ARG]...\n {0} FLAG",
|
||||||
|
uucore::execution_phrase()
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_vendor = "apple")]
|
#[cfg(target_vendor = "apple")]
|
||||||
|
|
|
@ -28,7 +28,7 @@ static OPT_IGNORE: &str = "ignore";
|
||||||
static ABOUT: &str = "Print the number of cores available to the current process.";
|
static ABOUT: &str = "Print the number of cores available to the current process.";
|
||||||
|
|
||||||
fn usage() -> String {
|
fn usage() -> String {
|
||||||
format!("{0} [OPTIONS]...", execution_phrase!())
|
format!("{0} [OPTIONS]...", uucore::execution_phrase())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uumain(args: impl uucore::Args) -> i32 {
|
pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
|
@ -70,7 +70,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uu_app() -> App<'static, 'static> {
|
pub fn uu_app() -> App<'static, 'static> {
|
||||||
App::new(util_name!())
|
App::new(uucore::util_name())
|
||||||
.version(crate_version!())
|
.version(crate_version!())
|
||||||
.about(ABOUT)
|
.about(ABOUT)
|
||||||
.arg(
|
.arg(
|
||||||
|
|
|
@ -51,7 +51,7 @@ Multiple fields/ranges can be separated with commas
|
||||||
";
|
";
|
||||||
|
|
||||||
fn usage() -> String {
|
fn usage() -> String {
|
||||||
format!("{0} [OPTION]... [NUMBER]...", execution_phrase!())
|
format!("{0} [OPTION]... [NUMBER]...", uucore::execution_phrase())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_args<'a>(args: impl Iterator<Item = &'a str>, options: NumfmtOptions) -> Result<()> {
|
fn handle_args<'a>(args: impl Iterator<Item = &'a str>, options: NumfmtOptions) -> Result<()> {
|
||||||
|
@ -175,7 +175,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uu_app() -> App<'static, 'static> {
|
pub fn uu_app() -> App<'static, 'static> {
|
||||||
App::new(util_name!())
|
App::new(uucore::util_name())
|
||||||
.version(crate_version!())
|
.version(crate_version!())
|
||||||
.about(ABOUT)
|
.about(ABOUT)
|
||||||
.after_help(LONG_HELP)
|
.after_help(LONG_HELP)
|
||||||
|
|
|
@ -57,7 +57,7 @@ impl<'b> MultifileReader<'b> {
|
||||||
// print an error at the time that the file is needed,
|
// print an error at the time that the file is needed,
|
||||||
// then move on the the next file.
|
// then move on the the next file.
|
||||||
// This matches the behavior of the original `od`
|
// This matches the behavior of the original `od`
|
||||||
eprintln!("{}: '{}': {}", util_name!(), fname, e);
|
eprintln!("{}: '{}': {}", uucore::util_name(), fname, e);
|
||||||
self.any_err = true
|
self.any_err = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -90,7 +90,7 @@ impl<'b> io::Read for MultifileReader<'b> {
|
||||||
Ok(0) => break,
|
Ok(0) => break,
|
||||||
Ok(n) => n,
|
Ok(n) => n,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
eprintln!("{}: I/O: {}", util_name!(), e);
|
eprintln!("{}: I/O: {}", uucore::util_name(), e);
|
||||||
self.any_err = true;
|
self.any_err = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -252,7 +252,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uu_app() -> clap::App<'static, 'static> {
|
pub fn uu_app() -> clap::App<'static, 'static> {
|
||||||
clap::App::new(util_name!())
|
clap::App::new(uucore::util_name())
|
||||||
.version(crate_version!())
|
.version(crate_version!())
|
||||||
.about(ABOUT)
|
.about(ABOUT)
|
||||||
.usage(USAGE)
|
.usage(USAGE)
|
||||||
|
|
|
@ -52,7 +52,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uu_app() -> App<'static, 'static> {
|
pub fn uu_app() -> App<'static, 'static> {
|
||||||
App::new(util_name!())
|
App::new(uucore::util_name())
|
||||||
.version(crate_version!())
|
.version(crate_version!())
|
||||||
.about(ABOUT)
|
.about(ABOUT)
|
||||||
.arg(
|
.arg(
|
||||||
|
|
|
@ -39,7 +39,7 @@ const POSIX_PATH_MAX: usize = 256;
|
||||||
const POSIX_NAME_MAX: usize = 14;
|
const POSIX_NAME_MAX: usize = 14;
|
||||||
|
|
||||||
fn usage() -> String {
|
fn usage() -> String {
|
||||||
format!("{0} [OPTION]... NAME...", execution_phrase!())
|
format!("{0} [OPTION]... NAME...", uucore::execution_phrase())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uumain(args: impl uucore::Args) -> i32 {
|
pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
|
@ -70,7 +70,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
let mut res = if paths.is_none() {
|
let mut res = if paths.is_none() {
|
||||||
show_error!(
|
show_error!(
|
||||||
"missing operand\nTry '{} --help' for more information",
|
"missing operand\nTry '{} --help' for more information",
|
||||||
execution_phrase!()
|
uucore::execution_phrase()
|
||||||
);
|
);
|
||||||
false
|
false
|
||||||
} else {
|
} else {
|
||||||
|
@ -98,7 +98,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uu_app() -> App<'static, 'static> {
|
pub fn uu_app() -> App<'static, 'static> {
|
||||||
App::new(util_name!())
|
App::new(uucore::util_name())
|
||||||
.version(crate_version!())
|
.version(crate_version!())
|
||||||
.about(ABOUT)
|
.about(ABOUT)
|
||||||
.arg(
|
.arg(
|
||||||
|
|
|
@ -41,7 +41,7 @@ mod options {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn usage() -> String {
|
fn usage() -> String {
|
||||||
format!("{0} [OPTION]... [USER]...", execution_phrase!())
|
format!("{0} [OPTION]... [USER]...", uucore::execution_phrase())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_long_usage() -> String {
|
fn get_long_usage() -> String {
|
||||||
|
@ -130,7 +130,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uu_app() -> App<'static, 'static> {
|
pub fn uu_app() -> App<'static, 'static> {
|
||||||
App::new(util_name!())
|
App::new(uucore::util_name())
|
||||||
.version(crate_version!())
|
.version(crate_version!())
|
||||||
.about(ABOUT)
|
.about(ABOUT)
|
||||||
.arg(
|
.arg(
|
||||||
|
|
|
@ -23,7 +23,6 @@ use std::fs::{metadata, File};
|
||||||
use std::io::{stdin, stdout, BufRead, BufReader, Lines, Read, Stdout, Write};
|
use std::io::{stdin, stdout, BufRead, BufReader, Lines, Read, Stdout, Write};
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
use std::os::unix::fs::FileTypeExt;
|
use std::os::unix::fs::FileTypeExt;
|
||||||
use uucore::util_name;
|
|
||||||
|
|
||||||
type IOError = std::io::Error;
|
type IOError = std::io::Error;
|
||||||
|
|
||||||
|
@ -170,7 +169,7 @@ quick_error! {
|
||||||
|
|
||||||
pub fn uu_app() -> clap::App<'static, 'static> {
|
pub fn uu_app() -> clap::App<'static, 'static> {
|
||||||
// TODO: migrate to clap to get more shell completions
|
// TODO: migrate to clap to get more shell completions
|
||||||
clap::App::new(util_name!())
|
clap::App::new(uucore::util_name())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uumain(args: impl uucore::Args) -> i32 {
|
pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
|
|
|
@ -7,9 +7,6 @@
|
||||||
|
|
||||||
/* last synced with: printenv (GNU coreutils) 8.13 */
|
/* last synced with: printenv (GNU coreutils) 8.13 */
|
||||||
|
|
||||||
#[macro_use]
|
|
||||||
extern crate uucore;
|
|
||||||
|
|
||||||
use clap::{crate_version, App, Arg};
|
use clap::{crate_version, App, Arg};
|
||||||
use std::env;
|
use std::env;
|
||||||
|
|
||||||
|
@ -20,7 +17,7 @@ static OPT_NULL: &str = "null";
|
||||||
static ARG_VARIABLES: &str = "variables";
|
static ARG_VARIABLES: &str = "variables";
|
||||||
|
|
||||||
fn usage() -> String {
|
fn usage() -> String {
|
||||||
format!("{0} [VARIABLE]... [OPTION]...", execution_phrase!())
|
format!("{0} [VARIABLE]... [OPTION]...", uucore::execution_phrase())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uumain(args: impl uucore::Args) -> i32 {
|
pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
|
@ -55,7 +52,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uu_app() -> App<'static, 'static> {
|
pub fn uu_app() -> App<'static, 'static> {
|
||||||
App::new(util_name!())
|
App::new(uucore::util_name())
|
||||||
.version(crate_version!())
|
.version(crate_version!())
|
||||||
.about(ABOUT)
|
.about(ABOUT)
|
||||||
.arg(
|
.arg(
|
||||||
|
|
|
@ -2,9 +2,6 @@
|
||||||
// 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
|
||||||
|
|
||||||
#[macro_use]
|
|
||||||
extern crate uucore;
|
|
||||||
|
|
||||||
use clap::{crate_version, App, Arg};
|
use clap::{crate_version, App, Arg};
|
||||||
use uucore::InvalidEncodingHandling;
|
use uucore::InvalidEncodingHandling;
|
||||||
|
|
||||||
|
@ -284,8 +281,8 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
if args.len() <= 1 {
|
if args.len() <= 1 {
|
||||||
println!(
|
println!(
|
||||||
"{0}: missing operand\nTry '{1} --help' for more information.",
|
"{0}: missing operand\nTry '{1} --help' for more information.",
|
||||||
util_name!(),
|
uucore::util_name(),
|
||||||
execution_phrase!()
|
uucore::execution_phrase()
|
||||||
);
|
);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -294,7 +291,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
if formatstr == "--help" {
|
if formatstr == "--help" {
|
||||||
print!("{} {}", LONGHELP_LEAD, LONGHELP_BODY);
|
print!("{} {}", LONGHELP_LEAD, LONGHELP_BODY);
|
||||||
} else if formatstr == "--version" {
|
} else if formatstr == "--version" {
|
||||||
println!("{} {}", util_name!(), crate_version!());
|
println!("{} {}", uucore::util_name(), crate_version!());
|
||||||
} else {
|
} else {
|
||||||
let printf_args = &args[2..];
|
let printf_args = &args[2..];
|
||||||
memo::Memo::run_all(formatstr, printf_args);
|
memo::Memo::run_all(formatstr, printf_args);
|
||||||
|
@ -303,7 +300,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uu_app() -> App<'static, 'static> {
|
pub fn uu_app() -> App<'static, 'static> {
|
||||||
App::new(util_name!())
|
App::new(uucore::util_name())
|
||||||
.arg(Arg::with_name(VERSION).long(VERSION))
|
.arg(Arg::with_name(VERSION).long(VERSION))
|
||||||
.arg(Arg::with_name(HELP).long(HELP))
|
.arg(Arg::with_name(HELP).long(HELP))
|
||||||
}
|
}
|
||||||
|
|
|
@ -659,7 +659,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uu_app() -> App<'static, 'static> {
|
pub fn uu_app() -> App<'static, 'static> {
|
||||||
App::new(util_name!())
|
App::new(uucore::util_name())
|
||||||
.name(NAME)
|
.name(NAME)
|
||||||
.version(crate_version!())
|
.version(crate_version!())
|
||||||
.usage(BRIEF)
|
.usage(BRIEF)
|
||||||
|
|
|
@ -35,7 +35,7 @@ pub fn absolute_path(path: &Path) -> io::Result<PathBuf> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn usage() -> String {
|
fn usage() -> String {
|
||||||
format!("{0} [OPTION]... FILE...", execution_phrase!())
|
format!("{0} [OPTION]... FILE...", uucore::execution_phrase())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[uucore_procs::gen_uumain]
|
#[uucore_procs::gen_uumain]
|
||||||
|
@ -66,7 +66,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uu_app() -> App<'static, 'static> {
|
pub fn uu_app() -> App<'static, 'static> {
|
||||||
App::new(util_name!())
|
App::new(uucore::util_name())
|
||||||
.version(crate_version!())
|
.version(crate_version!())
|
||||||
.about(ABOUT)
|
.about(ABOUT)
|
||||||
.arg(
|
.arg(
|
||||||
|
|
|
@ -29,7 +29,7 @@ const OPT_ZERO: &str = "zero";
|
||||||
const ARG_FILES: &str = "files";
|
const ARG_FILES: &str = "files";
|
||||||
|
|
||||||
fn usage() -> String {
|
fn usage() -> String {
|
||||||
format!("{0} [OPTION]... [FILE]...", execution_phrase!())
|
format!("{0} [OPTION]... [FILE]...", uucore::execution_phrase())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uumain(args: impl uucore::Args) -> i32 {
|
pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
|
@ -59,14 +59,14 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
crash!(
|
crash!(
|
||||||
1,
|
1,
|
||||||
"missing operand\nTry '{} --help' for more information",
|
"missing operand\nTry '{} --help' for more information",
|
||||||
execution_phrase!()
|
uucore::execution_phrase()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if no_newline && files.len() > 1 && !silent {
|
if no_newline && files.len() > 1 && !silent {
|
||||||
eprintln!(
|
eprintln!(
|
||||||
"{}: ignoring --no-newline with multiple arguments",
|
"{}: ignoring --no-newline with multiple arguments",
|
||||||
util_name!()
|
uucore::util_name()
|
||||||
);
|
);
|
||||||
no_newline = false;
|
no_newline = false;
|
||||||
}
|
}
|
||||||
|
@ -80,7 +80,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
if verbose {
|
if verbose {
|
||||||
eprintln!(
|
eprintln!(
|
||||||
"{}: {}: errno {}",
|
"{}: {}: errno {}",
|
||||||
util_name!(),
|
uucore::util_name(),
|
||||||
f,
|
f,
|
||||||
err.raw_os_error().unwrap()
|
err.raw_os_error().unwrap()
|
||||||
);
|
);
|
||||||
|
@ -95,7 +95,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
if verbose {
|
if verbose {
|
||||||
eprintln!(
|
eprintln!(
|
||||||
"{}: {}: errno {:?}",
|
"{}: {}: errno {:?}",
|
||||||
util_name!(),
|
uucore::util_name(),
|
||||||
f,
|
f,
|
||||||
err.raw_os_error().unwrap()
|
err.raw_os_error().unwrap()
|
||||||
);
|
);
|
||||||
|
@ -110,7 +110,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uu_app() -> App<'static, 'static> {
|
pub fn uu_app() -> App<'static, 'static> {
|
||||||
App::new(util_name!())
|
App::new(uucore::util_name())
|
||||||
.version(crate_version!())
|
.version(crate_version!())
|
||||||
.about(ABOUT)
|
.about(ABOUT)
|
||||||
.arg(
|
.arg(
|
||||||
|
|
|
@ -23,7 +23,7 @@ static OPT_ZERO: &str = "zero";
|
||||||
static ARG_FILES: &str = "files";
|
static ARG_FILES: &str = "files";
|
||||||
|
|
||||||
fn usage() -> String {
|
fn usage() -> String {
|
||||||
format!("{0} [OPTION]... FILE...", execution_phrase!())
|
format!("{0} [OPTION]... FILE...", uucore::execution_phrase())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uumain(args: impl uucore::Args) -> i32 {
|
pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
|
@ -55,7 +55,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uu_app() -> App<'static, 'static> {
|
pub fn uu_app() -> App<'static, 'static> {
|
||||||
App::new(util_name!())
|
App::new(uucore::util_name())
|
||||||
.version(crate_version!())
|
.version(crate_version!())
|
||||||
.about(ABOUT)
|
.about(ABOUT)
|
||||||
.arg(
|
.arg(
|
||||||
|
|
|
@ -7,9 +7,6 @@
|
||||||
|
|
||||||
// spell-checker:ignore (ToDO) subpath absto absfrom absbase
|
// spell-checker:ignore (ToDO) subpath absto absfrom absbase
|
||||||
|
|
||||||
#[macro_use]
|
|
||||||
extern crate uucore;
|
|
||||||
|
|
||||||
use clap::{crate_version, App, Arg};
|
use clap::{crate_version, App, Arg};
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
|
@ -26,7 +23,7 @@ mod options {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn usage() -> String {
|
fn usage() -> String {
|
||||||
format!("{} [-d DIR] TO [FROM]", execution_phrase!())
|
format!("{} [-d DIR] TO [FROM]", uucore::execution_phrase())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uumain(args: impl uucore::Args) -> i32 {
|
pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
|
@ -82,7 +79,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uu_app() -> App<'static, 'static> {
|
pub fn uu_app() -> App<'static, 'static> {
|
||||||
App::new(util_name!())
|
App::new(uucore::util_name())
|
||||||
.version(crate_version!())
|
.version(crate_version!())
|
||||||
.about(ABOUT)
|
.about(ABOUT)
|
||||||
.arg(
|
.arg(
|
||||||
|
|
|
@ -53,7 +53,7 @@ static OPT_VERBOSE: &str = "verbose";
|
||||||
static ARG_FILES: &str = "files";
|
static ARG_FILES: &str = "files";
|
||||||
|
|
||||||
fn usage() -> String {
|
fn usage() -> String {
|
||||||
format!("{0} [OPTION]... FILE...", execution_phrase!())
|
format!("{0} [OPTION]... FILE...", uucore::execution_phrase())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_long_usage() -> String {
|
fn get_long_usage() -> String {
|
||||||
|
@ -93,7 +93,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
// Still check by hand and not use clap
|
// Still check by hand and not use clap
|
||||||
// Because "rm -f" is a thing
|
// Because "rm -f" is a thing
|
||||||
show_error!("missing an argument");
|
show_error!("missing an argument");
|
||||||
show_error!("for help, try '{0} --help'", execution_phrase!());
|
show_error!("for help, try '{0} --help'", uucore::execution_phrase());
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
let options = Options {
|
let options = Options {
|
||||||
|
@ -140,7 +140,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uu_app() -> App<'static, 'static> {
|
pub fn uu_app() -> App<'static, 'static> {
|
||||||
App::new(util_name!())
|
App::new(uucore::util_name())
|
||||||
.version(crate_version!())
|
.version(crate_version!())
|
||||||
.about(ABOUT)
|
.about(ABOUT)
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ static ENOTDIR: i32 = 20;
|
||||||
static ENOTDIR: i32 = 267;
|
static ENOTDIR: i32 = 267;
|
||||||
|
|
||||||
fn usage() -> String {
|
fn usage() -> String {
|
||||||
format!("{0} [OPTION]... DIRECTORY...", execution_phrase!())
|
format!("{0} [OPTION]... DIRECTORY...", uucore::execution_phrase())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uumain(args: impl uucore::Args) -> i32 {
|
pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
|
@ -53,7 +53,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uu_app() -> App<'static, 'static> {
|
pub fn uu_app() -> App<'static, 'static> {
|
||||||
App::new(util_name!())
|
App::new(uucore::util_name())
|
||||||
.version(crate_version!())
|
.version(crate_version!())
|
||||||
.about(ABOUT)
|
.about(ABOUT)
|
||||||
.arg(
|
.arg(
|
||||||
|
|
|
@ -27,7 +27,7 @@ fn usage() -> String {
|
||||||
"{0} [OPTION]... LAST
|
"{0} [OPTION]... LAST
|
||||||
{0} [OPTION]... FIRST LAST
|
{0} [OPTION]... FIRST LAST
|
||||||
{0} [OPTION]... FIRST INCREMENT LAST",
|
{0} [OPTION]... FIRST INCREMENT LAST",
|
||||||
execution_phrase!()
|
uucore::execution_phrase()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
|
@ -72,13 +72,13 @@ impl FromStr for Number {
|
||||||
Ok(value) if value.is_nan() => Err(format!(
|
Ok(value) if value.is_nan() => Err(format!(
|
||||||
"invalid 'not-a-number' argument: '{}'\nTry '{} --help' for more information.",
|
"invalid 'not-a-number' argument: '{}'\nTry '{} --help' for more information.",
|
||||||
s,
|
s,
|
||||||
execution_phrase!(),
|
uucore::execution_phrase(),
|
||||||
)),
|
)),
|
||||||
Ok(value) => Ok(Number::F64(value)),
|
Ok(value) => Ok(Number::F64(value)),
|
||||||
Err(_) => Err(format!(
|
Err(_) => Err(format!(
|
||||||
"invalid floating point argument: '{}'\nTry '{} --help' for more information.",
|
"invalid floating point argument: '{}'\nTry '{} --help' for more information.",
|
||||||
s,
|
s,
|
||||||
execution_phrase!(),
|
uucore::execution_phrase(),
|
||||||
)),
|
)),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -123,7 +123,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
show_error!(
|
show_error!(
|
||||||
"invalid Zero increment value: '{}'\nTry '{} --help' for more information.",
|
"invalid Zero increment value: '{}'\nTry '{} --help' for more information.",
|
||||||
numbers[1],
|
numbers[1],
|
||||||
execution_phrase!()
|
uucore::execution_phrase()
|
||||||
);
|
);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -163,7 +163,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uu_app() -> App<'static, 'static> {
|
pub fn uu_app() -> App<'static, 'static> {
|
||||||
App::new(util_name!())
|
App::new(uucore::util_name())
|
||||||
.setting(AppSettings::AllowLeadingHyphen)
|
.setting(AppSettings::AllowLeadingHyphen)
|
||||||
.version(crate_version!())
|
.version(crate_version!())
|
||||||
.about(ABOUT)
|
.about(ABOUT)
|
||||||
|
|
|
@ -214,7 +214,7 @@ for even very expensive hardware probing to recover the data.
|
||||||
";
|
";
|
||||||
|
|
||||||
fn usage() -> String {
|
fn usage() -> String {
|
||||||
format!("{} [OPTION]... FILE...", execution_phrase!())
|
format!("{} [OPTION]... FILE...", uucore::execution_phrase())
|
||||||
}
|
}
|
||||||
|
|
||||||
static AFTER_HELP: &str =
|
static AFTER_HELP: &str =
|
||||||
|
@ -330,7 +330,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uu_app() -> App<'static, 'static> {
|
pub fn uu_app() -> App<'static, 'static> {
|
||||||
App::new(util_name!())
|
App::new(uucore::util_name())
|
||||||
.version(crate_version!())
|
.version(crate_version!())
|
||||||
.about(ABOUT)
|
.about(ABOUT)
|
||||||
.after_help(AFTER_HELP)
|
.after_help(AFTER_HELP)
|
||||||
|
|
|
@ -115,7 +115,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uu_app() -> App<'static, 'static> {
|
pub fn uu_app() -> App<'static, 'static> {
|
||||||
App::new(util_name!())
|
App::new(uucore::util_name())
|
||||||
.name(NAME)
|
.name(NAME)
|
||||||
.version(crate_version!())
|
.version(crate_version!())
|
||||||
.template(TEMPLATE)
|
.template(TEMPLATE)
|
||||||
|
|
|
@ -29,7 +29,7 @@ mod options {
|
||||||
fn usage() -> String {
|
fn usage() -> String {
|
||||||
format!(
|
format!(
|
||||||
"{0} {1}[SUFFIX]... \n {0} OPTION",
|
"{0} {1}[SUFFIX]... \n {0} OPTION",
|
||||||
execution_phrase!(),
|
uucore::execution_phrase(),
|
||||||
options::NUMBER
|
options::NUMBER
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uu_app() -> App<'static, 'static> {
|
pub fn uu_app() -> App<'static, 'static> {
|
||||||
App::new(util_name!())
|
App::new(uucore::util_name())
|
||||||
.version(crate_version!())
|
.version(crate_version!())
|
||||||
.about(ABOUT)
|
.about(ABOUT)
|
||||||
.after_help(LONG_HELP)
|
.after_help(LONG_HELP)
|
||||||
|
|
|
@ -1060,7 +1060,7 @@ fn usage() -> String {
|
||||||
Write the sorted concatenation of all FILE(s) to standard output.
|
Write the sorted concatenation of all FILE(s) to standard output.
|
||||||
Mandatory arguments for long options are mandatory for short options too.
|
Mandatory arguments for long options are mandatory for short options too.
|
||||||
With no FILE, or when FILE is -, read standard input.",
|
With no FILE, or when FILE is -, read standard input.",
|
||||||
execution_phrase!()
|
uucore::execution_phrase()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1286,7 +1286,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uu_app() -> App<'static, 'static> {
|
pub fn uu_app() -> App<'static, 'static> {
|
||||||
App::new(util_name!())
|
App::new(uucore::util_name())
|
||||||
.version(crate_version!())
|
.version(crate_version!())
|
||||||
.about(ABOUT)
|
.about(ABOUT)
|
||||||
.arg(
|
.arg(
|
||||||
|
|
|
@ -35,7 +35,10 @@ static ARG_INPUT: &str = "input";
|
||||||
static ARG_PREFIX: &str = "prefix";
|
static ARG_PREFIX: &str = "prefix";
|
||||||
|
|
||||||
fn usage() -> String {
|
fn usage() -> String {
|
||||||
format!("{0} [OPTION]... [INPUT [PREFIX]]", execution_phrase!())
|
format!(
|
||||||
|
"{0} [OPTION]... [INPUT [PREFIX]]",
|
||||||
|
uucore::execution_phrase()
|
||||||
|
)
|
||||||
}
|
}
|
||||||
fn get_long_usage() -> String {
|
fn get_long_usage() -> String {
|
||||||
format!(
|
format!(
|
||||||
|
@ -125,7 +128,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uu_app() -> App<'static, 'static> {
|
pub fn uu_app() -> App<'static, 'static> {
|
||||||
App::new(util_name!())
|
App::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")
|
||||||
// strategy (mutually exclusive)
|
// strategy (mutually exclusive)
|
||||||
|
|
|
@ -883,7 +883,7 @@ impl Stater {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn usage() -> String {
|
fn usage() -> String {
|
||||||
format!("{0} [OPTION]... FILE...", execution_phrase!())
|
format!("{0} [OPTION]... FILE...", uucore::execution_phrase())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_long_usage() -> String {
|
fn get_long_usage() -> String {
|
||||||
|
@ -963,7 +963,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uu_app() -> App<'static, 'static> {
|
pub fn uu_app() -> App<'static, 'static> {
|
||||||
App::new(util_name!())
|
App::new(uucore::util_name())
|
||||||
.version(crate_version!())
|
.version(crate_version!())
|
||||||
.about(ABOUT)
|
.about(ABOUT)
|
||||||
.arg(
|
.arg(
|
||||||
|
|
|
@ -48,7 +48,7 @@ mod options {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn usage() -> String {
|
fn usage() -> String {
|
||||||
format!("{0} OPTION... COMMAND", execution_phrase!())
|
format!("{0} OPTION... COMMAND", uucore::execution_phrase())
|
||||||
}
|
}
|
||||||
|
|
||||||
const STDBUF_INJECT: &[u8] = include_bytes!(concat!(env!("OUT_DIR"), "/libstdbuf.so"));
|
const STDBUF_INJECT: &[u8] = include_bytes!(concat!(env!("OUT_DIR"), "/libstdbuf.so"));
|
||||||
|
@ -161,7 +161,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
125,
|
125,
|
||||||
"{}\nTry '{} --help' for more information.",
|
"{}\nTry '{} --help' for more information.",
|
||||||
e.0,
|
e.0,
|
||||||
execution_phrase!()
|
uucore::execution_phrase()
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -191,7 +191,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uu_app() -> App<'static, 'static> {
|
pub fn uu_app() -> App<'static, 'static> {
|
||||||
App::new(util_name!())
|
App::new(uucore::util_name())
|
||||||
.version(crate_version!())
|
.version(crate_version!())
|
||||||
.about(ABOUT)
|
.about(ABOUT)
|
||||||
.after_help(LONG_HELP)
|
.after_help(LONG_HELP)
|
||||||
|
|
|
@ -140,7 +140,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uu_app() -> App<'static, 'static> {
|
pub fn uu_app() -> App<'static, 'static> {
|
||||||
App::new(util_name!())
|
App::new(uucore::util_name())
|
||||||
.name(NAME)
|
.name(NAME)
|
||||||
.version(crate_version!())
|
.version(crate_version!())
|
||||||
.usage(USAGE)
|
.usage(USAGE)
|
||||||
|
|
|
@ -160,7 +160,7 @@ mod platform {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn usage() -> String {
|
fn usage() -> String {
|
||||||
format!("{0} [OPTION]... FILE...", execution_phrase!())
|
format!("{0} [OPTION]... FILE...", uucore::execution_phrase())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uumain(args: impl uucore::Args) -> i32 {
|
pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
|
@ -193,7 +193,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uu_app() -> App<'static, 'static> {
|
pub fn uu_app() -> App<'static, 'static> {
|
||||||
App::new(util_name!())
|
App::new(uucore::util_name())
|
||||||
.version(crate_version!())
|
.version(crate_version!())
|
||||||
.about(ABOUT)
|
.about(ABOUT)
|
||||||
.arg(
|
.arg(
|
||||||
|
|
|
@ -51,7 +51,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uu_app() -> App<'static, 'static> {
|
pub fn uu_app() -> App<'static, 'static> {
|
||||||
App::new(util_name!())
|
App::new(uucore::util_name())
|
||||||
.name(NAME)
|
.name(NAME)
|
||||||
.version(crate_version!())
|
.version(crate_version!())
|
||||||
.usage(USAGE)
|
.usage(USAGE)
|
||||||
|
|
|
@ -213,7 +213,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uu_app() -> App<'static, 'static> {
|
pub fn uu_app() -> App<'static, 'static> {
|
||||||
App::new(util_name!())
|
App::new(uucore::util_name())
|
||||||
.version(crate_version!())
|
.version(crate_version!())
|
||||||
.about("output the last part of files")
|
.about("output the last part of files")
|
||||||
// TODO: add usage
|
// TODO: add usage
|
||||||
|
|
|
@ -33,7 +33,7 @@ struct Options {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn usage() -> String {
|
fn usage() -> String {
|
||||||
format!("{0} [OPTION]... [FILE]...", execution_phrase!())
|
format!("{0} [OPTION]... [FILE]...", uucore::execution_phrase())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uumain(args: impl uucore::Args) -> i32 {
|
pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
|
@ -57,7 +57,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uu_app() -> App<'static, 'static> {
|
pub fn uu_app() -> App<'static, 'static> {
|
||||||
App::new(util_name!())
|
App::new(uucore::util_name())
|
||||||
.version(crate_version!())
|
.version(crate_version!())
|
||||||
.about(ABOUT)
|
.about(ABOUT)
|
||||||
.after_help("If a FILE is -, it refers to a file named - .")
|
.after_help("If a FILE is -, it refers to a file named - .")
|
||||||
|
|
|
@ -14,7 +14,6 @@ use clap::{crate_version, App, AppSettings};
|
||||||
use parser::{parse, Symbol};
|
use parser::{parse, Symbol};
|
||||||
use std::ffi::{OsStr, OsString};
|
use std::ffi::{OsStr, OsString};
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use uucore::util_name;
|
|
||||||
|
|
||||||
const USAGE: &str = "test EXPRESSION
|
const USAGE: &str = "test EXPRESSION
|
||||||
or: test
|
or: test
|
||||||
|
@ -87,7 +86,7 @@ the version described here. Please refer to your shell's documentation
|
||||||
for details about the options it supports.";
|
for details about the options it supports.";
|
||||||
|
|
||||||
pub fn uu_app() -> App<'static, 'static> {
|
pub fn uu_app() -> App<'static, 'static> {
|
||||||
App::new(util_name!())
|
App::new(uucore::util_name())
|
||||||
.setting(AppSettings::DisableHelpFlags)
|
.setting(AppSettings::DisableHelpFlags)
|
||||||
.setting(AppSettings::DisableVersion)
|
.setting(AppSettings::DisableVersion)
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,10 @@ use uucore::InvalidEncodingHandling;
|
||||||
static ABOUT: &str = "Start COMMAND, and kill it if still running after DURATION.";
|
static ABOUT: &str = "Start COMMAND, and kill it if still running after DURATION.";
|
||||||
|
|
||||||
fn usage() -> String {
|
fn usage() -> String {
|
||||||
format!("{0} [OPTION] DURATION COMMAND...", execution_phrase!())
|
format!(
|
||||||
|
"{0} [OPTION] DURATION COMMAND...",
|
||||||
|
uucore::execution_phrase()
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const ERR_EXIT_STATUS: i32 = 125;
|
const ERR_EXIT_STATUS: i32 = 125;
|
||||||
|
|
|
@ -48,7 +48,7 @@ fn local_tm_to_filetime(tm: time::Tm) -> FileTime {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn usage() -> String {
|
fn usage() -> String {
|
||||||
format!("{0} [OPTION]... [USER]", execution_phrase!())
|
format!("{0} [OPTION]... [USER]", uucore::execution_phrase())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[uucore_procs::gen_uumain]
|
#[uucore_procs::gen_uumain]
|
||||||
|
@ -129,7 +129,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uu_app() -> App<'static, 'static> {
|
pub fn uu_app() -> App<'static, 'static> {
|
||||||
App::new(util_name!())
|
App::new(uucore::util_name())
|
||||||
.version(crate_version!())
|
.version(crate_version!())
|
||||||
.about(ABOUT)
|
.about(ABOUT)
|
||||||
.arg(
|
.arg(
|
||||||
|
|
|
@ -229,7 +229,7 @@ fn translate_input<T: SymbolTranslator>(
|
||||||
}
|
}
|
||||||
|
|
||||||
fn usage() -> String {
|
fn usage() -> String {
|
||||||
format!("{} [OPTION]... SET1 [SET2]", execution_phrase!())
|
format!("{} [OPTION]... SET1 [SET2]", uucore::execution_phrase())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_long_usage() -> String {
|
fn get_long_usage() -> String {
|
||||||
|
@ -264,7 +264,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
if sets.is_empty() {
|
if sets.is_empty() {
|
||||||
show_error!(
|
show_error!(
|
||||||
"missing operand\nTry '{} --help' for more information.",
|
"missing operand\nTry '{} --help' for more information.",
|
||||||
execution_phrase!()
|
uucore::execution_phrase()
|
||||||
);
|
);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -273,7 +273,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
show_error!(
|
show_error!(
|
||||||
"missing operand after '{}'\nTry '{} --help' for more information.",
|
"missing operand after '{}'\nTry '{} --help' for more information.",
|
||||||
sets[0],
|
sets[0],
|
||||||
execution_phrase!()
|
uucore::execution_phrase()
|
||||||
);
|
);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -312,7 +312,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uu_app() -> App<'static, 'static> {
|
pub fn uu_app() -> App<'static, 'static> {
|
||||||
App::new(util_name!())
|
App::new(uucore::util_name())
|
||||||
.version(crate_version!())
|
.version(crate_version!())
|
||||||
.about(ABOUT)
|
.about(ABOUT)
|
||||||
.arg(
|
.arg(
|
||||||
|
|
|
@ -10,7 +10,6 @@ extern crate uucore;
|
||||||
|
|
||||||
use clap::App;
|
use clap::App;
|
||||||
use uucore::error::UResult;
|
use uucore::error::UResult;
|
||||||
use uucore::util_name;
|
|
||||||
|
|
||||||
#[uucore_procs::gen_uumain]
|
#[uucore_procs::gen_uumain]
|
||||||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
|
@ -19,5 +18,5 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uu_app() -> App<'static, 'static> {
|
pub fn uu_app() -> App<'static, 'static> {
|
||||||
App::new(util_name!())
|
App::new(uucore::util_name())
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,7 +64,7 @@ pub mod options {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn usage() -> String {
|
fn usage() -> String {
|
||||||
format!("{0} [OPTION]... [FILE]...", execution_phrase!())
|
format!("{0} [OPTION]... [FILE]...", uucore::execution_phrase())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_long_usage() -> String {
|
fn get_long_usage() -> String {
|
||||||
|
@ -133,7 +133,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uu_app() -> App<'static, 'static> {
|
pub fn uu_app() -> App<'static, 'static> {
|
||||||
App::new(util_name!())
|
App::new(uucore::util_name())
|
||||||
.version(crate_version!())
|
.version(crate_version!())
|
||||||
.about(ABOUT)
|
.about(ABOUT)
|
||||||
.arg(
|
.arg(
|
||||||
|
|
|
@ -90,7 +90,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uu_app() -> App<'static, 'static> {
|
pub fn uu_app() -> App<'static, 'static> {
|
||||||
App::new(util_name!())
|
App::new(uucore::util_name())
|
||||||
.version(crate_version!())
|
.version(crate_version!())
|
||||||
.usage(USAGE)
|
.usage(USAGE)
|
||||||
.about(SUMMARY)
|
.about(SUMMARY)
|
||||||
|
|
|
@ -9,9 +9,6 @@
|
||||||
|
|
||||||
// spell-checker:ignore (ToDO) ttyname filedesc
|
// spell-checker:ignore (ToDO) ttyname filedesc
|
||||||
|
|
||||||
#[macro_use]
|
|
||||||
extern crate uucore;
|
|
||||||
|
|
||||||
use clap::{crate_version, App, Arg};
|
use clap::{crate_version, App, Arg};
|
||||||
use std::ffi::CStr;
|
use std::ffi::CStr;
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
|
@ -24,7 +21,7 @@ mod options {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn usage() -> String {
|
fn usage() -> String {
|
||||||
format!("{0} [OPTION]...", execution_phrase!())
|
format!("{0} [OPTION]...", uucore::execution_phrase())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uumain(args: impl uucore::Args) -> i32 {
|
pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
|
@ -78,7 +75,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uu_app() -> App<'static, 'static> {
|
pub fn uu_app() -> App<'static, 'static> {
|
||||||
App::new(util_name!())
|
App::new(uucore::util_name())
|
||||||
.version(crate_version!())
|
.version(crate_version!())
|
||||||
.about(ABOUT)
|
.about(ABOUT)
|
||||||
.arg(
|
.arg(
|
||||||
|
|
|
@ -50,7 +50,7 @@ const HOST_OS: &str = "Fuchsia";
|
||||||
const HOST_OS: &str = "Redox";
|
const HOST_OS: &str = "Redox";
|
||||||
|
|
||||||
pub fn uumain(args: impl uucore::Args) -> i32 {
|
pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
let usage = format!("{} [OPTION]...", execution_phrase!());
|
let usage = format!("{} [OPTION]...", uucore::execution_phrase());
|
||||||
let matches = uu_app().usage(&usage[..]).get_matches_from(args);
|
let matches = uu_app().usage(&usage[..]).get_matches_from(args);
|
||||||
|
|
||||||
let uname = return_if_err!(1, PlatformInfo::new());
|
let uname = return_if_err!(1, PlatformInfo::new());
|
||||||
|
@ -119,7 +119,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uu_app() -> App<'static, 'static> {
|
pub fn uu_app() -> App<'static, 'static> {
|
||||||
App::new(util_name!())
|
App::new(uucore::util_name())
|
||||||
.version(crate_version!())
|
.version(crate_version!())
|
||||||
.about(ABOUT)
|
.about(ABOUT)
|
||||||
.arg(Arg::with_name(options::ALL)
|
.arg(Arg::with_name(options::ALL)
|
||||||
|
|
|
@ -102,7 +102,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uu_app() -> App<'static, 'static> {
|
pub fn uu_app() -> App<'static, 'static> {
|
||||||
App::new(util_name!())
|
App::new(uucore::util_name())
|
||||||
.name(NAME)
|
.name(NAME)
|
||||||
.version(crate_version!())
|
.version(crate_version!())
|
||||||
.usage(USAGE)
|
.usage(USAGE)
|
||||||
|
|
|
@ -222,7 +222,10 @@ fn opt_parsed<T: FromStr>(opt_name: &str, matches: &ArgMatches) -> Option<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn usage() -> String {
|
fn usage() -> String {
|
||||||
format!("{0} [OPTION]... [INPUT [OUTPUT]]...", execution_phrase!())
|
format!(
|
||||||
|
"{0} [OPTION]... [INPUT [OUTPUT]]...",
|
||||||
|
uucore::execution_phrase()
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_long_usage() -> String {
|
fn get_long_usage() -> String {
|
||||||
|
@ -281,7 +284,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uu_app() -> App<'static, 'static> {
|
pub fn uu_app() -> App<'static, 'static> {
|
||||||
App::new(util_name!())
|
App::new(uucore::util_name())
|
||||||
.version(crate_version!())
|
.version(crate_version!())
|
||||||
.about(ABOUT)
|
.about(ABOUT)
|
||||||
.arg(
|
.arg(
|
||||||
|
|
|
@ -23,7 +23,7 @@ static ABOUT: &str = "Unlink the file at [FILE].";
|
||||||
static OPT_PATH: &str = "FILE";
|
static OPT_PATH: &str = "FILE";
|
||||||
|
|
||||||
fn usage() -> String {
|
fn usage() -> String {
|
||||||
format!("{} [OPTION]... FILE", execution_phrase!())
|
format!("{} [OPTION]... FILE", uucore::execution_phrase())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uumain(args: impl uucore::Args) -> i32 {
|
pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
|
@ -44,13 +44,13 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
crash!(
|
crash!(
|
||||||
1,
|
1,
|
||||||
"missing operand\nTry '{0} --help' for more information.",
|
"missing operand\nTry '{0} --help' for more information.",
|
||||||
execution_phrase!()
|
uucore::execution_phrase()
|
||||||
);
|
);
|
||||||
} else if paths.len() > 1 {
|
} else if paths.len() > 1 {
|
||||||
crash!(
|
crash!(
|
||||||
1,
|
1,
|
||||||
"extra operand: '{1}'\nTry '{0} --help' for more information.",
|
"extra operand: '{1}'\nTry '{0} --help' for more information.",
|
||||||
execution_phrase!(),
|
uucore::execution_phrase(),
|
||||||
paths[1]
|
paths[1]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -95,7 +95,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uu_app() -> App<'static, 'static> {
|
pub fn uu_app() -> App<'static, 'static> {
|
||||||
App::new(util_name!())
|
App::new(uucore::util_name())
|
||||||
.version(crate_version!())
|
.version(crate_version!())
|
||||||
.about(ABOUT)
|
.about(ABOUT)
|
||||||
.arg(Arg::with_name(OPT_PATH).hidden(true).multiple(true))
|
.arg(Arg::with_name(OPT_PATH).hidden(true).multiple(true))
|
||||||
|
|
|
@ -33,7 +33,7 @@ extern "C" {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn usage() -> String {
|
fn usage() -> String {
|
||||||
format!("{0} [OPTION]...", execution_phrase!())
|
format!("{0} [OPTION]...", uucore::execution_phrase())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uumain(args: impl uucore::Args) -> i32 {
|
pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
|
@ -64,7 +64,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uu_app() -> App<'static, 'static> {
|
pub fn uu_app() -> App<'static, 'static> {
|
||||||
App::new(util_name!())
|
App::new(uucore::util_name())
|
||||||
.version(crate_version!())
|
.version(crate_version!())
|
||||||
.about(ABOUT)
|
.about(ABOUT)
|
||||||
.arg(
|
.arg(
|
||||||
|
|
|
@ -8,9 +8,6 @@
|
||||||
|
|
||||||
// spell-checker:ignore (paths) wtmp
|
// spell-checker:ignore (paths) wtmp
|
||||||
|
|
||||||
#[macro_use]
|
|
||||||
extern crate uucore;
|
|
||||||
|
|
||||||
use clap::{crate_version, App, Arg};
|
use clap::{crate_version, App, Arg};
|
||||||
use uucore::utmpx::{self, Utmpx};
|
use uucore::utmpx::{self, Utmpx};
|
||||||
|
|
||||||
|
@ -19,7 +16,7 @@ static ABOUT: &str = "Print the user names of users currently logged in to the c
|
||||||
static ARG_FILES: &str = "files";
|
static ARG_FILES: &str = "files";
|
||||||
|
|
||||||
fn usage() -> String {
|
fn usage() -> String {
|
||||||
format!("{0} [FILE]", execution_phrase!())
|
format!("{0} [FILE]", uucore::execution_phrase())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_long_usage() -> String {
|
fn get_long_usage() -> String {
|
||||||
|
@ -65,7 +62,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uu_app() -> App<'static, 'static> {
|
pub fn uu_app() -> App<'static, 'static> {
|
||||||
App::new(util_name!())
|
App::new(uucore::util_name())
|
||||||
.version(crate_version!())
|
.version(crate_version!())
|
||||||
.about(ABOUT)
|
.about(ABOUT)
|
||||||
.arg(Arg::with_name(ARG_FILES).takes_value(true).max_values(1))
|
.arg(Arg::with_name(ARG_FILES).takes_value(true).max_values(1))
|
||||||
|
|
|
@ -99,7 +99,7 @@ fn usage() -> String {
|
||||||
format!(
|
format!(
|
||||||
"{0} [OPTION]... [FILE]...
|
"{0} [OPTION]... [FILE]...
|
||||||
With no FILE, or when FILE is -, read standard input.",
|
With no FILE, or when FILE is -, read standard input.",
|
||||||
execution_phrase!()
|
uucore::execution_phrase()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -164,7 +164,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uu_app() -> App<'static, 'static> {
|
pub fn uu_app() -> App<'static, 'static> {
|
||||||
App::new(util_name!())
|
App::new(uucore::util_name())
|
||||||
.version(crate_version!())
|
.version(crate_version!())
|
||||||
.about(ABOUT)
|
.about(ABOUT)
|
||||||
.arg(
|
.arg(
|
||||||
|
|
|
@ -45,7 +45,10 @@ static RUNLEVEL_HELP: &str = "print current runlevel";
|
||||||
static RUNLEVEL_HELP: &str = "print current runlevel (This is meaningless on non Linux)";
|
static RUNLEVEL_HELP: &str = "print current runlevel (This is meaningless on non Linux)";
|
||||||
|
|
||||||
fn usage() -> String {
|
fn usage() -> String {
|
||||||
format!("{0} [OPTION]... [ FILE | ARG1 ARG2 ]", execution_phrase!())
|
format!(
|
||||||
|
"{0} [OPTION]... [ FILE | ARG1 ARG2 ]",
|
||||||
|
uucore::execution_phrase()
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_long_usage() -> String {
|
fn get_long_usage() -> String {
|
||||||
|
@ -160,7 +163,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uu_app() -> App<'static, 'static> {
|
pub fn uu_app() -> App<'static, 'static> {
|
||||||
App::new(util_name!())
|
App::new(uucore::util_name())
|
||||||
.version(crate_version!())
|
.version(crate_version!())
|
||||||
.about(ABOUT)
|
.about(ABOUT)
|
||||||
.arg(
|
.arg(
|
||||||
|
|
|
@ -87,6 +87,38 @@ pub fn set_utility_is_second_arg() {
|
||||||
crate::macros::UTILITY_IS_SECOND_ARG.store(true, Ordering::SeqCst)
|
crate::macros::UTILITY_IS_SECOND_ARG.store(true, Ordering::SeqCst)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Get the executable path (as `OsString`).
|
||||||
|
fn executable_os() -> OsString {
|
||||||
|
args_os().next().unwrap()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Get the executable path (as `String`).
|
||||||
|
fn executable() -> String {
|
||||||
|
executable_os().to_string_lossy().into_owned()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Derive the utility name.
|
||||||
|
pub fn util_name() -> String {
|
||||||
|
if get_utility_is_second_arg() {
|
||||||
|
args_os().nth(1).unwrap().to_string_lossy().into_owned()
|
||||||
|
} else {
|
||||||
|
executable()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Derive the complete execution phrase for "usage".
|
||||||
|
pub fn execution_phrase() -> String {
|
||||||
|
if get_utility_is_second_arg() {
|
||||||
|
args_os()
|
||||||
|
.take(2)
|
||||||
|
.map(|os_str| os_str.to_string_lossy().into_owned())
|
||||||
|
.collect::<Vec<_>>()
|
||||||
|
.join(" ")
|
||||||
|
} else {
|
||||||
|
executable()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub enum InvalidEncodingHandling {
|
pub enum InvalidEncodingHandling {
|
||||||
Ignore,
|
Ignore,
|
||||||
ConvertLossy,
|
ConvertLossy,
|
||||||
|
|
|
@ -10,67 +10,14 @@ use std::sync::atomic::AtomicBool;
|
||||||
/// Whether we were called as a multicall binary ("coreutils <utility>")
|
/// Whether we were called as a multicall binary ("coreutils <utility>")
|
||||||
pub static UTILITY_IS_SECOND_ARG: AtomicBool = AtomicBool::new(false);
|
pub static UTILITY_IS_SECOND_ARG: AtomicBool = AtomicBool::new(false);
|
||||||
|
|
||||||
/// Get the executable path (as `OsString`).
|
|
||||||
#[macro_export]
|
|
||||||
macro_rules! executable_os(
|
|
||||||
() => ({
|
|
||||||
$crate::args_os().next().unwrap()
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
/// Get the executable path (as `String`).
|
|
||||||
#[macro_export]
|
|
||||||
#[deprecated = "Use util_name!() or execution_phrase!() instead"]
|
|
||||||
macro_rules! executable(
|
|
||||||
() => ({
|
|
||||||
$crate::executable_os!().to_string_lossy().to_string()
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
/// Derive the utility name.
|
|
||||||
#[macro_export]
|
|
||||||
macro_rules! util_name(
|
|
||||||
() => ({
|
|
||||||
if $crate::get_utility_is_second_arg() {
|
|
||||||
$crate::args_os().nth(1).unwrap().to_string_lossy().to_string()
|
|
||||||
} else {
|
|
||||||
#[allow(deprecated)]
|
|
||||||
{
|
|
||||||
$crate::executable!()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
//====
|
|
||||||
|
|
||||||
/// Derive the complete execution phrase for "usage".
|
|
||||||
#[macro_export]
|
|
||||||
macro_rules! execution_phrase(
|
|
||||||
() => ({
|
|
||||||
if $crate::get_utility_is_second_arg() {
|
|
||||||
$crate::args_os()
|
|
||||||
.take(2)
|
|
||||||
.map(|os_str| os_str.to_string_lossy().to_string())
|
|
||||||
.collect::<Vec<_>>()
|
|
||||||
.join(" ")
|
|
||||||
} else {
|
|
||||||
#[allow(deprecated)]
|
|
||||||
{
|
|
||||||
$crate::executable!()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
//====
|
//====
|
||||||
|
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! show(
|
macro_rules! show(
|
||||||
($err:expr) => ({
|
($err:expr) => ({
|
||||||
let e = $err;
|
let e = $err;
|
||||||
uucore::error::set_exit_code(e.code());
|
$crate::error::set_exit_code(e.code());
|
||||||
eprintln!("{}: {}", $crate::util_name!(), e);
|
eprintln!("{}: {}", $crate::util_name(), e);
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -87,7 +34,7 @@ macro_rules! show_if_err(
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! show_error(
|
macro_rules! show_error(
|
||||||
($($args:tt)+) => ({
|
($($args:tt)+) => ({
|
||||||
eprint!("{}: ", $crate::util_name!());
|
eprint!("{}: ", $crate::util_name());
|
||||||
eprintln!($($args)+);
|
eprintln!($($args)+);
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
@ -96,7 +43,7 @@ macro_rules! show_error(
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! show_error_custom_description (
|
macro_rules! show_error_custom_description (
|
||||||
($err:expr,$($args:tt)+) => ({
|
($err:expr,$($args:tt)+) => ({
|
||||||
eprint!("{}: {}: ", $crate::util_name!(), $err);
|
eprint!("{}: {}: ", $crate::util_name(), $err);
|
||||||
eprintln!($($args)+);
|
eprintln!($($args)+);
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
@ -104,7 +51,7 @@ macro_rules! show_error_custom_description (
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! show_warning(
|
macro_rules! show_warning(
|
||||||
($($args:tt)+) => ({
|
($($args:tt)+) => ({
|
||||||
eprint!("{}: warning: ", $crate::util_name!());
|
eprint!("{}: warning: ", $crate::util_name());
|
||||||
eprintln!($($args)+);
|
eprintln!($($args)+);
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
@ -113,9 +60,9 @@ macro_rules! show_warning(
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! show_usage_error(
|
macro_rules! show_usage_error(
|
||||||
($($args:tt)+) => ({
|
($($args:tt)+) => ({
|
||||||
eprint!("{}: ", $crate::util_name!());
|
eprint!("{}: ", $crate::util_name());
|
||||||
eprintln!($($args)+);
|
eprintln!($($args)+);
|
||||||
eprintln!("Try '{} --help' for more information.", $crate::execution_phrase!());
|
eprintln!("Try '{} --help' for more information.", $crate::execution_phrase());
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -120,7 +120,7 @@ impl<'a> CoreOptions<'a> {
|
||||||
macro_rules! app {
|
macro_rules! app {
|
||||||
($syntax: expr, $summary: expr, $long_help: expr) => {
|
($syntax: expr, $summary: expr, $long_help: expr) => {
|
||||||
uucore::coreopts::CoreOptions::new(uucore::coreopts::HelpText {
|
uucore::coreopts::CoreOptions::new(uucore::coreopts::HelpText {
|
||||||
name: util_name!(),
|
name: uucore::util_name(),
|
||||||
version: env!("CARGO_PKG_VERSION"),
|
version: env!("CARGO_PKG_VERSION"),
|
||||||
syntax: $syntax,
|
syntax: $syntax,
|
||||||
summary: $summary,
|
summary: $summary,
|
||||||
|
@ -130,7 +130,7 @@ macro_rules! app {
|
||||||
};
|
};
|
||||||
($syntax: expr, $summary: expr, $long_help: expr, $display_usage: expr) => {
|
($syntax: expr, $summary: expr, $long_help: expr, $display_usage: expr) => {
|
||||||
uucore::coreopts::CoreOptions::new(uucore::coreopts::HelpText {
|
uucore::coreopts::CoreOptions::new(uucore::coreopts::HelpText {
|
||||||
name: util_name!(),
|
name: uucore::util_name(),
|
||||||
version: env!("CARGO_PKG_VERSION"),
|
version: env!("CARGO_PKG_VERSION"),
|
||||||
syntax: $syntax,
|
syntax: $syntax,
|
||||||
summary: $summary,
|
summary: $summary,
|
||||||
|
|
|
@ -104,7 +104,7 @@ pub fn gen_uumain(_args: TokenStream, stream: TokenStream) -> TokenStream {
|
||||||
show_error!("{}", s);
|
show_error!("{}", s);
|
||||||
}
|
}
|
||||||
if e.usage() {
|
if e.usage() {
|
||||||
eprintln!("Try '{} --help' for more information.", execution_phrase!());
|
eprintln!("Try '{} --help' for more information.", uucore::execution_phrase());
|
||||||
}
|
}
|
||||||
e.code()
|
e.code()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue