1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-29 03:57:44 +00:00

change ~ new_coreopts!() => app!() (from uucore v0.0.4)

This commit is contained in:
Roy Ivy III 2020-05-27 11:14:16 -05:00
parent 4b8fc7445b
commit ea3235c7e2
32 changed files with 32 additions and 32 deletions

View file

@ -17,7 +17,7 @@ static SUMMARY: &str = "Determine architecture name for current machine.";
static LONG_HELP: &str = ""; static LONG_HELP: &str = "";
pub fn uumain(args: Vec<String>) -> i32 { pub fn uumain(args: Vec<String>) -> i32 {
new_coreopts!(SYNTAX, SUMMARY, LONG_HELP).parse(args); app!(SYNTAX, SUMMARY, LONG_HELP).parse(args);
let uts = return_if_err!(1, PlatformInfo::new()); let uts = return_if_err!(1, PlatformInfo::new());
println!("{}", uts.machine().trim()); println!("{}", uts.machine().trim());
0 0

View file

@ -20,7 +20,7 @@ pub fn execute(
long_help: &str, long_help: &str,
format: Format, format: Format,
) -> i32 { ) -> i32 {
let matches = new_coreopts!(syntax, summary, long_help) let matches = app!(syntax, summary, long_help)
.optflag("d", "decode", "decode data") .optflag("d", "decode", "decode data")
.optflag( .optflag(
"i", "i",

View file

@ -20,7 +20,7 @@ pub fn execute(
long_help: &str, long_help: &str,
format: Format, format: Format,
) -> i32 { ) -> i32 {
let matches = new_coreopts!(syntax, summary, long_help) let matches = app!(syntax, summary, long_help)
.optflag("d", "decode", "decode data") .optflag("d", "decode", "decode data")
.optflag( .optflag(
"i", "i",

View file

@ -20,7 +20,7 @@ pub fn uumain(args: Vec<String>) -> i32 {
// //
// Argument parsing // Argument parsing
// //
let matches = new_coreopts!(SYNTAX, SUMMARY, LONG_HELP) let matches = app!(SYNTAX, SUMMARY, LONG_HELP)
.optflag( .optflag(
"a", "a",
"multiple", "multiple",

View file

@ -123,7 +123,7 @@ enum InputType {
type CatResult<T> = Result<T, CatError>; type CatResult<T> = Result<T, CatError>;
pub fn uumain(args: Vec<String>) -> i32 { pub fn uumain(args: Vec<String>) -> i32 {
let matches = new_coreopts!(SYNTAX, SUMMARY, LONG_HELP) let matches = app!(SYNTAX, SUMMARY, LONG_HELP)
.optflag("A", "show-all", "equivalent to -vET") .optflag("A", "show-all", "equivalent to -vET")
.optflag( .optflag(
"b", "b",

View file

@ -35,7 +35,7 @@ const FTS_PHYSICAL: u8 = 1 << 1;
const FTS_LOGICAL: u8 = 1 << 2; const FTS_LOGICAL: u8 = 1 << 2;
pub fn uumain(args: Vec<String>) -> i32 { pub fn uumain(args: Vec<String>) -> i32 {
let mut opts = new_coreopts!(SYNTAX, SUMMARY, ""); let mut opts = app!(SYNTAX, SUMMARY, "");
opts.optflag("c", opts.optflag("c",
"changes", "changes",
"like verbose but report only when a change is made") "like verbose but report only when a change is made")

View file

@ -34,7 +34,7 @@ pub fn uumain(mut args: Vec<String>) -> i32 {
{0} [OPTION]... --reference=RFILE FILE...", {0} [OPTION]... --reference=RFILE FILE...",
NAME NAME
); );
let mut opts = new_coreopts!(&syntax, SUMMARY, LONG_HELP); let mut opts = app!(&syntax, SUMMARY, LONG_HELP);
opts.optflag( opts.optflag(
"c", "c",
"changes", "changes",

View file

@ -37,7 +37,7 @@ const FTS_PHYSICAL: u8 = 1 << 1;
const FTS_LOGICAL: u8 = 1 << 2; const FTS_LOGICAL: u8 = 1 << 2;
pub fn uumain(args: Vec<String>) -> i32 { pub fn uumain(args: Vec<String>) -> i32 {
let mut opts = new_coreopts!(SYNTAX, SUMMARY, ""); let mut opts = app!(SYNTAX, SUMMARY, "");
opts.optflag("c", opts.optflag("c",
"changes", "changes",
"like verbose but report only when a change is made") "like verbose but report only when a change is made")

View file

@ -28,7 +28,7 @@ static LONG_HELP: &str = "
"; ";
pub fn uumain(args: Vec<String>) -> i32 { pub fn uumain(args: Vec<String>) -> i32 {
let matches = new_coreopts!(SYNTAX, SUMMARY, LONG_HELP) let matches = app!(SYNTAX, SUMMARY, LONG_HELP)
.optopt( .optopt(
"u", "u",
"user", "user",

View file

@ -70,7 +70,7 @@ fn cksum(fname: &str) -> io::Result<(u32, usize)> {
} }
pub fn uumain(args: Vec<String>) -> i32 { pub fn uumain(args: Vec<String>) -> i32 {
let matches = new_coreopts!(SYNTAX, SUMMARY, LONG_HELP).parse(args); let matches = app!(SYNTAX, SUMMARY, LONG_HELP).parse(args);
let files = matches.free; let files = matches.free;

View file

@ -120,7 +120,7 @@ fn open_file(name: &str) -> io::Result<LineReader> {
} }
pub fn uumain(args: Vec<String>) -> i32 { pub fn uumain(args: Vec<String>) -> i32 {
let matches = new_coreopts!(SYNTAX, SUMMARY, LONG_HELP) let matches = app!(SYNTAX, SUMMARY, LONG_HELP)
.optflag("1", "", "suppress column 1 (lines uniq to FILE1)") .optflag("1", "", "suppress column 1 (lines uniq to FILE1)")
.optflag("2", "", "suppress column 2 (lines uniq to FILE2)") .optflag("2", "", "suppress column 2 (lines uniq to FILE2)")
.optflag( .optflag(

View file

@ -422,7 +422,7 @@ fn cut_files(mut filenames: Vec<String>, mode: Mode) -> i32 {
} }
pub fn uumain(args: Vec<String>) -> i32 { pub fn uumain(args: Vec<String>) -> i32 {
let matches = new_coreopts!(SYNTAX, SUMMARY, LONG_HELP) let matches = app!(SYNTAX, SUMMARY, LONG_HELP)
.optopt("b", "bytes", "filter byte columns from the input source", "sequence") .optopt("b", "bytes", "filter byte columns from the input source", "sequence")
.optopt("c", "characters", "alias for character mode", "sequence") .optopt("c", "characters", "alias for character mode", "sequence")
.optopt("d", "delimiter", "specify the delimiter character that separates fields in the input source. Defaults to Tab.", "delimiter") .optopt("d", "delimiter", "specify the delimiter character that separates fields in the input source. Defaults to Tab.", "delimiter")

View file

@ -53,7 +53,7 @@ pub fn guess_syntax() -> OutputFmt {
} }
pub fn uumain(args: Vec<String>) -> i32 { pub fn uumain(args: Vec<String>) -> i32 {
let matches = new_coreopts!(SYNTAX, SUMMARY, LONG_HELP) let matches = app!(SYNTAX, SUMMARY, LONG_HELP)
.optflag("b", "sh", "output Bourne shell code to set LS_COLORS") .optflag("b", "sh", "output Bourne shell code to set LS_COLORS")
.optflag( .optflag(
"", "",

View file

@ -20,7 +20,7 @@ static LONG_HELP: &str = "
"; ";
pub fn uumain(args: Vec<String>) -> i32 { pub fn uumain(args: Vec<String>) -> i32 {
let matches = new_coreopts!(SYNTAX, SUMMARY, LONG_HELP) let matches = app!(SYNTAX, SUMMARY, LONG_HELP)
.optflag("z", "zero", "separate output with NUL rather than newline") .optflag("z", "zero", "separate output with NUL rather than newline")
.parse(args); .parse(args);

View file

@ -229,7 +229,7 @@ pub fn uumain(args: Vec<String>) -> i32 {
{0} [OPTION]... --files0-from=F", {0} [OPTION]... --files0-from=F",
NAME NAME
); );
let matches = new_coreopts!(&syntax, SUMMARY, LONG_HELP) let matches = app!(&syntax, SUMMARY, LONG_HELP)
// In task // In task
.optflag( .optflag(
"a", "a",

View file

@ -103,7 +103,7 @@ fn print_escaped(input: &str, mut output: impl Write) -> io::Result<bool> {
} }
pub fn uumain(args: Vec<String>) -> i32 { pub fn uumain(args: Vec<String>) -> i32 {
let matches = new_coreopts!(SYNTAX, SUMMARY, HELP) let matches = app!(SYNTAX, SUMMARY, HELP)
.optflag("n", "", "do not output the trailing newline") .optflag("n", "", "do not output the trailing newline")
.optflag("e", "", "enable interpretation of backslash escapes") .optflag("e", "", "enable interpretation of backslash escapes")
.optflag( .optflag(

View file

@ -99,7 +99,7 @@ impl Options {
} }
pub fn uumain(args: Vec<String>) -> i32 { pub fn uumain(args: Vec<String>) -> i32 {
let matches = new_coreopts!(SYNTAX, SUMMARY, LONG_HELP) let matches = app!(SYNTAX, SUMMARY, LONG_HELP)
.optflag("i", "initial", "do not convert tabs after non blanks") .optflag("i", "initial", "do not convert tabs after non blanks")
.optopt( .optopt(
"t", "t",

View file

@ -116,7 +116,7 @@ fn print_factors_str(num_str: &str) {
} }
pub fn uumain(args: Vec<String>) -> i32 { pub fn uumain(args: Vec<String>) -> i32 {
let matches = new_coreopts!(SYNTAX, SUMMARY, LONG_HELP).parse(args); let matches = app!(SYNTAX, SUMMARY, LONG_HELP).parse(args);
if matches.free.is_empty() { if matches.free.is_empty() {
let stdin = stdin(); let stdin = stdin();

View file

@ -56,7 +56,7 @@ pub struct FmtOptions {
#[allow(clippy::cognitive_complexity)] #[allow(clippy::cognitive_complexity)]
pub fn uumain(args: Vec<String>) -> i32 { pub fn uumain(args: Vec<String>) -> i32 {
let matches = new_coreopts!(SYNTAX, SUMMARY, LONG_HELP) let matches = app!(SYNTAX, SUMMARY, LONG_HELP)
.optflag("c", "crown-margin", "First and second line of paragraph may have different indentations, in which case the first line's indentation is preserved, and each subsequent line's indentation matches the second line.") .optflag("c", "crown-margin", "First and second line of paragraph may have different indentations, in which case the first line's indentation is preserved, and each subsequent line's indentation matches the second line.")
.optflag("t", "tagged-paragraph", "Like -c, except that the first and second line of a paragraph *must* have different indentation or they are treated as separate paragraphs.") .optflag("t", "tagged-paragraph", "Like -c, except that the first and second line of a paragraph *must* have different indentation or they are treated as separate paragraphs.")
.optflag("m", "preserve-headers", "Attempt to detect and preserve mail headers in the input. Be careful when combining this flag with -p.") .optflag("m", "preserve-headers", "Attempt to detect and preserve mail headers in the input. Be careful when combining this flag with -p.")

View file

@ -19,7 +19,7 @@ static LONG_HELP: &str = "";
pub fn uumain(args: Vec<String>) -> i32 { pub fn uumain(args: Vec<String>) -> i32 {
let (args, obs_width) = handle_obsolete(&args[..]); let (args, obs_width) = handle_obsolete(&args[..]);
let matches = new_coreopts!(SYNTAX, SUMMARY, LONG_HELP) let matches = app!(SYNTAX, SUMMARY, LONG_HELP)
.optflag( .optflag(
"b", "b",
"bytes", "bytes",

View file

@ -14,7 +14,7 @@ static SYNTAX: &str = "[user]";
static SUMMARY: &str = "display current group names"; static SUMMARY: &str = "display current group names";
pub fn uumain(args: Vec<String>) -> i32 { pub fn uumain(args: Vec<String>) -> i32 {
let matches = new_coreopts!(SYNTAX, SUMMARY, "").parse(args); let matches = app!(SYNTAX, SUMMARY, "").parse(args);
if matches.free.is_empty() { if matches.free.is_empty() {
println!( println!(

View file

@ -52,7 +52,7 @@ pub fn uumain(args: Vec<String>) -> i32 {
(args, None) => args, (args, None) => args,
}; };
let matches = new_coreopts!(SYNTAX, SUMMARY, LONG_HELP) let matches = app!(SYNTAX, SUMMARY, LONG_HELP)
.optopt( .optopt(
"c", "c",
"bytes", "bytes",

View file

@ -22,7 +22,7 @@ extern "C" {
} }
pub fn uumain(args: Vec<String>) -> i32 { pub fn uumain(args: Vec<String>) -> i32 {
new_coreopts!(SYNTAX, SUMMARY, LONG_HELP).parse(args); app!(SYNTAX, SUMMARY, LONG_HELP).parse(args);
hostid(); hostid();
0 0
} }

View file

@ -70,7 +70,7 @@ static SYNTAX: &str = "[OPTION]... [USER]";
static SUMMARY: &str = "Print user and group information for the specified USER,\n or (when USER omitted) for the current user."; static SUMMARY: &str = "Print user and group information for the specified USER,\n or (when USER omitted) for the current user.";
pub fn uumain(args: Vec<String>) -> i32 { pub fn uumain(args: Vec<String>) -> i32 {
let mut opts = new_coreopts!(SYNTAX, SUMMARY, ""); let mut opts = app!(SYNTAX, SUMMARY, "");
opts.optflag( opts.optflag(
"A", "A",
"", "",

View file

@ -96,7 +96,7 @@ fn parse_opts(args: Vec<String>) -> getopts::Matches {
{} SOURCE... DIRECTORY", {} SOURCE... DIRECTORY",
NAME NAME
); );
new_coreopts!(&syntax, SUMMARY, LONG_HELP) app!(&syntax, SUMMARY, LONG_HELP)
// TODO implement flag // TODO implement flag
.optflagopt( .optflagopt(
"", "",

View file

@ -30,7 +30,7 @@ pub enum Mode {
pub fn uumain(args: Vec<String>) -> i32 { pub fn uumain(args: Vec<String>) -> i32 {
let (args, obs_signal) = handle_obsolete(args); let (args, obs_signal) = handle_obsolete(args);
let matches = new_coreopts!(SYNTAX, SUMMARY, LONG_HELP) let matches = app!(SYNTAX, SUMMARY, LONG_HELP)
.optopt("s", "signal", "specify the <signal> to be sent", "SIGNAL") .optopt("s", "signal", "specify the <signal> to be sent", "SIGNAL")
.optflagopt( .optflagopt(
"l", "l",

View file

@ -24,7 +24,7 @@ pub fn normalize_error_message(e: Error) -> String {
} }
pub fn uumain(args: Vec<String>) -> i32 { pub fn uumain(args: Vec<String>) -> i32 {
let matches = new_coreopts!(SYNTAX, SUMMARY, LONG_HELP).parse(args); let matches = app!(SYNTAX, SUMMARY, LONG_HELP).parse(args);
if matches.free.len() != 2 { if matches.free.len() != 2 {
crash!(1, "{}", msg_wrong_number_of_arguments!(2)); crash!(1, "{}", msg_wrong_number_of_arguments!(2));
} }

View file

@ -62,7 +62,7 @@ pub fn uumain(args: Vec<String>) -> i32 {
{0} [OPTION]... -t DIRECTORY TARGET... (4th form)", {0} [OPTION]... -t DIRECTORY TARGET... (4th form)",
NAME NAME
); );
let matches = new_coreopts!(&syntax, SUMMARY, LONG_HELP) let matches = app!(&syntax, SUMMARY, LONG_HELP)
.optflag( .optflag(
"b", "b",
"", "",

View file

@ -35,7 +35,7 @@ static SUMMARY: &str = "Print user's login name";
static LONG_HELP: &str = ""; static LONG_HELP: &str = "";
pub fn uumain(args: Vec<String>) -> i32 { pub fn uumain(args: Vec<String>) -> i32 {
new_coreopts!(SYNTAX, SUMMARY, LONG_HELP).parse(args); app!(SYNTAX, SUMMARY, LONG_HELP).parse(args);
exec(); exec();

View file

@ -80,7 +80,7 @@ pub fn uumain(args: Vec<String>) -> i32 {
{0} [OPTION]... [FILE]...", {0} [OPTION]... [FILE]...",
NAME NAME
); );
let matches = new_coreopts!(&syntax, SUMMARY, LONG_HELP) let matches = app!(&syntax, SUMMARY, LONG_HELP)
.optflag("1", "", "list one file per line.") .optflag("1", "", "list one file per line.")
.optflag( .optflag(
"a", "a",

View file

@ -47,7 +47,7 @@ pub fn uumain(args: Vec<String>) -> i32 {
The utmp file will be {}", The utmp file will be {}",
utmpx::DEFAULT_FILE utmpx::DEFAULT_FILE
); );
let mut opts = new_coreopts!(SYNTAX, SUMMARY, &long_help); let mut opts = app!(SYNTAX, SUMMARY, &long_help);
opts.optflag( opts.optflag(
"l", "l",
"", "",

View file

@ -45,7 +45,7 @@ If ARG1 ARG2 given, -m presumed: 'am i' or 'mom likes' are usual.
"; ";
pub fn uumain(args: Vec<String>) -> i32 { pub fn uumain(args: Vec<String>) -> i32 {
let mut opts = new_coreopts!(SYNTAX, SUMMARY, LONG_HELP); let mut opts = app!(SYNTAX, SUMMARY, LONG_HELP);
opts.optflag("a", "all", "same as -b -d --login -p -r -t -T -u"); opts.optflag("a", "all", "same as -b -d --login -p -r -t -T -u");
opts.optflag("b", "boot", "time of last system boot"); opts.optflag("b", "boot", "time of last system boot");
opts.optflag("d", "dead", "print dead processes"); opts.optflag("d", "dead", "print dead processes");