mirror of
https://github.com/uutils/coreutils
synced 2024-12-13 23:02:38 +00:00
Add more consistency in the --help output and declarations
This commit is contained in:
parent
e1991525af
commit
d957a11f34
27 changed files with 58 additions and 52 deletions
|
@ -13,6 +13,7 @@ use uucore::{encoding::Format, error::UResult};
|
|||
pub mod base_common;
|
||||
|
||||
static ABOUT: &str = "\
|
||||
encode/decode data and print to standard output
|
||||
With no FILE, or when FILE is -, read standard input.
|
||||
|
||||
The data are encoded as described for the base32 alphabet in RFC
|
||||
|
|
|
@ -14,6 +14,7 @@ use uucore::{encoding::Format, error::UResult};
|
|||
use std::io::{stdin, Read};
|
||||
|
||||
static ABOUT: &str = "\
|
||||
encode/decode data and print to standard output
|
||||
With no FILE, or when FILE is -, read standard input.
|
||||
|
||||
The data are encoded as described for the base64 alphabet in RFC
|
||||
|
|
|
@ -13,8 +13,8 @@ use uucore::display::Quotable;
|
|||
use uucore::error::{UResult, UUsageError};
|
||||
use uucore::{format_usage, InvalidEncodingHandling};
|
||||
|
||||
static SUMMARY: &str = "Print NAME with any leading directory components removed
|
||||
If specified, also remove a trailing SUFFIX";
|
||||
static ABOUT: &str = r#"Print NAME with any leading directory components removed
|
||||
If specified, also remove a trailing SUFFIX"#;
|
||||
|
||||
const USAGE: &str = "{} NAME [SUFFIX]
|
||||
{} OPTION... NAME...";
|
||||
|
@ -107,7 +107,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
|||
pub fn uu_app<'a>() -> Command<'a> {
|
||||
Command::new(uucore::util_name())
|
||||
.version(crate_version!())
|
||||
.about(SUMMARY)
|
||||
.about(ABOUT)
|
||||
.override_usage(format_usage(USAGE))
|
||||
.infer_long_args(true)
|
||||
.arg(
|
||||
|
|
|
@ -21,6 +21,7 @@ use std::io::{stdin, Read};
|
|||
use uucore::error::UClapError;
|
||||
|
||||
static ABOUT: &str = "\
|
||||
encode/decode data and print to standard output
|
||||
With no FILE, or when FILE is -, read standard input.
|
||||
|
||||
When decoding, the input may contain newlines in addition to the bytes of
|
||||
|
|
|
@ -40,8 +40,8 @@ use uucore::{format_usage, InvalidEncodingHandling};
|
|||
|
||||
static NAME: &str = "cat";
|
||||
static USAGE: &str = "{} [OPTION]... [FILE]...";
|
||||
static SUMMARY: &str = "Concatenate FILE(s), or standard input, to standard output
|
||||
With no FILE, or when FILE is -, read standard input.";
|
||||
static ABOUT: &str = "Concatenate FILE(s), or standard input, to standard output
|
||||
With no FILE, or when FILE is -, read standard input.";
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
enum CatError {
|
||||
|
@ -244,7 +244,7 @@ pub fn uu_app<'a>() -> Command<'a> {
|
|||
.name(NAME)
|
||||
.version(crate_version!())
|
||||
.override_usage(format_usage(USAGE))
|
||||
.about(SUMMARY)
|
||||
.about(ABOUT)
|
||||
.infer_long_args(true)
|
||||
.arg(
|
||||
Arg::new(options::FILE)
|
||||
|
|
|
@ -21,7 +21,7 @@ const CRC_TABLE: [u32; CRC_TABLE_LEN] = generate_crc_table();
|
|||
|
||||
const NAME: &str = "cksum";
|
||||
const USAGE: &str = "{} [OPTIONS] [FILE]...";
|
||||
const SUMMARY: &str = "Print CRC and size for each file";
|
||||
const ABOUT: &str = "Print CRC and size for each file";
|
||||
|
||||
const fn generate_crc_table() -> [u32; CRC_TABLE_LEN] {
|
||||
let mut table = [0; CRC_TABLE_LEN];
|
||||
|
@ -144,7 +144,7 @@ pub fn uu_app<'a>() -> Command<'a> {
|
|||
Command::new(uucore::util_name())
|
||||
.name(NAME)
|
||||
.version(crate_version!())
|
||||
.about(SUMMARY)
|
||||
.about(ABOUT)
|
||||
.override_usage(format_usage(USAGE))
|
||||
.infer_long_args(true)
|
||||
.arg(
|
||||
|
|
|
@ -25,7 +25,7 @@ mod split_name;
|
|||
use crate::csplit_error::CsplitError;
|
||||
use crate::split_name::SplitName;
|
||||
|
||||
static SUMMARY: &str = "split a file into sections determined by context lines";
|
||||
static ABOUT: &str = "split a file into sections determined by context lines";
|
||||
static LONG_HELP: &str = "Output pieces of FILE separated by PATTERN(s) to files 'xx00', 'xx01', ..., and output byte counts of each piece to standard output.";
|
||||
const USAGE: &str = "{} [OPTION]... FILE PATTERN...";
|
||||
|
||||
|
@ -749,7 +749,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
|||
pub fn uu_app<'a>() -> Command<'a> {
|
||||
Command::new(uucore::util_name())
|
||||
.version(crate_version!())
|
||||
.about(SUMMARY)
|
||||
.about(ABOUT)
|
||||
.override_usage(format_usage(USAGE))
|
||||
.infer_long_args(true)
|
||||
.arg(
|
||||
|
|
|
@ -27,7 +27,7 @@ mod searcher;
|
|||
static NAME: &str = "cut";
|
||||
static USAGE: &str =
|
||||
"{} [-d] [-s] [-z] [--output-delimiter] ((-f|-b|-c) {{sequence}}) {{sourcefile}}+";
|
||||
static SUMMARY: &str =
|
||||
static ABOUT: &str =
|
||||
"Prints specified byte or field columns from each line of stdin or the input files";
|
||||
static LONG_HELP: &str = "
|
||||
Each call must specify a mode (what to use for columns),
|
||||
|
@ -539,7 +539,7 @@ pub fn uu_app<'a>() -> Command<'a> {
|
|||
.name(NAME)
|
||||
.version(crate_version!())
|
||||
.override_usage(format_usage(USAGE))
|
||||
.about(SUMMARY)
|
||||
.about(ABOUT)
|
||||
.after_help(LONG_HELP)
|
||||
.infer_long_args(true)
|
||||
.arg(
|
||||
|
|
|
@ -26,7 +26,7 @@ mod options {
|
|||
}
|
||||
|
||||
static USAGE: &str = "{} [OPTION]... [FILE]";
|
||||
static SUMMARY: &str = "Output commands to set the LS_COLORS environment variable.";
|
||||
static ABOUT: &str = "Output commands to set the LS_COLORS environment variable.";
|
||||
static LONG_HELP: &str = "
|
||||
If FILE is specified, read it to determine which colors to use for which
|
||||
file types and extensions. Otherwise, a precompiled database is used.
|
||||
|
@ -173,7 +173,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
|||
pub fn uu_app<'a>() -> Command<'a> {
|
||||
Command::new(uucore::util_name())
|
||||
.version(crate_version!())
|
||||
.about(SUMMARY)
|
||||
.about(ABOUT)
|
||||
.after_help(LONG_HELP)
|
||||
.override_usage(format_usage(USAGE))
|
||||
.infer_long_args(true)
|
||||
|
|
|
@ -78,7 +78,7 @@ mod options {
|
|||
pub const FILE: &str = "FILE";
|
||||
}
|
||||
|
||||
const SUMMARY: &str = "estimate file space usage";
|
||||
const ABOUT: &str = "estimate file space usage";
|
||||
const LONG_HELP: &str = "
|
||||
Display values are in units of the first available SIZE from --block-size,
|
||||
and the DU_BLOCK_SIZE, BLOCK_SIZE and BLOCKSIZE environment variables.
|
||||
|
@ -729,7 +729,7 @@ fn parse_depth(max_depth_str: Option<&str>, summarize: bool) -> UResult<Option<u
|
|||
pub fn uu_app<'a>() -> Command<'a> {
|
||||
Command::new(uucore::util_name())
|
||||
.version(crate_version!())
|
||||
.about(SUMMARY)
|
||||
.about(ABOUT)
|
||||
.after_help(LONG_HELP)
|
||||
.override_usage(format_usage(USAGE))
|
||||
.infer_long_args(true)
|
||||
|
|
|
@ -14,7 +14,7 @@ use uucore::error::{FromIo, UResult};
|
|||
use uucore::{format_usage, InvalidEncodingHandling};
|
||||
|
||||
const NAME: &str = "echo";
|
||||
const SUMMARY: &str = "display a line of text";
|
||||
const ABOUT: &str = "display a line of text";
|
||||
const USAGE: &str = "{} [OPTIONS]... [STRING]...";
|
||||
const AFTER_HELP: &str = r#"
|
||||
Echo the STRING(s) to standard output.
|
||||
|
@ -136,7 +136,7 @@ pub fn uu_app<'a>() -> Command<'a> {
|
|||
.allow_hyphen_values(true)
|
||||
.infer_long_args(true)
|
||||
.version(crate_version!())
|
||||
.about(SUMMARY)
|
||||
.about(ABOUT)
|
||||
.after_help(AFTER_HELP)
|
||||
.override_usage(format_usage(USAGE))
|
||||
.arg(
|
||||
|
|
4
src/uu/env/src/env.rs
vendored
4
src/uu/env/src/env.rs
vendored
|
@ -31,6 +31,7 @@ use uucore::format_usage;
|
|||
#[cfg(unix)]
|
||||
use uucore::signals::signal_name_by_value;
|
||||
|
||||
const ABOUT: &str = "set each NAME to VALUE in the environment and run COMMAND";
|
||||
const USAGE: &str = "{} [OPTION]... [-] [NAME=VALUE]... [COMMAND [ARG]...]";
|
||||
const AFTER_HELP: &str = "\
|
||||
A mere - implies -i. If no COMMAND, print the resulting environment.
|
||||
|
@ -128,8 +129,7 @@ fn build_command<'a, 'b>(args: &'a mut Vec<&'b str>) -> (Cow<'b, str>, &'a [&'b
|
|||
pub fn uu_app<'a>() -> Command<'a> {
|
||||
Command::new(crate_name!())
|
||||
.version(crate_version!())
|
||||
.author(crate_authors!())
|
||||
.about(crate_description!())
|
||||
.about(ABOUT)
|
||||
.override_usage(format_usage(USAGE))
|
||||
.after_help(AFTER_HELP)
|
||||
.allow_external_subcommands(true)
|
||||
|
|
|
@ -14,15 +14,13 @@ mod tokens;
|
|||
|
||||
const VERSION: &str = "version";
|
||||
const HELP: &str = "help";
|
||||
static ABOUT: &str = "Print the value of EXPRESSION to standard output";
|
||||
static USAGE: &str = r#"
|
||||
static USAGE: &str = r#"Print the value of EXPRESSION to standard output
|
||||
expr [EXPRESSION]
|
||||
expr [OPTIONS]"#;
|
||||
|
||||
pub fn uu_app<'a>() -> Command<'a> {
|
||||
Command::new(uucore::util_name())
|
||||
.version(crate_version!())
|
||||
.about(ABOUT)
|
||||
.override_usage(USAGE)
|
||||
.infer_long_args(true)
|
||||
.arg(
|
||||
|
|
|
@ -25,8 +25,8 @@ pub mod numeric;
|
|||
mod rho;
|
||||
pub mod table;
|
||||
|
||||
static SUMMARY: &str = "Print the prime factors of the given NUMBER(s).
|
||||
If none are specified, read from standard input.";
|
||||
static ABOUT: &str = r#"Print the prime factors of the given NUMBER(s).
|
||||
If none are specified, read from standard input."#;
|
||||
|
||||
mod options {
|
||||
pub static NUMBER: &str = "NUMBER";
|
||||
|
@ -81,7 +81,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
|||
pub fn uu_app<'a>() -> Command<'a> {
|
||||
Command::new(uucore::util_name())
|
||||
.version(crate_version!())
|
||||
.about(SUMMARY)
|
||||
.about(ABOUT)
|
||||
.infer_long_args(true)
|
||||
.arg(Arg::new(options::NUMBER).multiple_occurrences(true))
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ const TAB_WIDTH: usize = 8;
|
|||
|
||||
static NAME: &str = "fold";
|
||||
static USAGE: &str = "{} [OPTION]... [FILE]...";
|
||||
static SUMMARY: &str = "Writes each file (or standard input if no files are given)
|
||||
static ABOUT: &str = "Writes each file (or standard input if no files are given)
|
||||
to standard output whilst breaking long lines";
|
||||
|
||||
mod options {
|
||||
|
@ -68,7 +68,7 @@ pub fn uu_app<'a>() -> Command<'a> {
|
|||
.name(NAME)
|
||||
.version(crate_version!())
|
||||
.override_usage(format_usage(USAGE))
|
||||
.about(SUMMARY)
|
||||
.about(ABOUT)
|
||||
.infer_long_args(true)
|
||||
.arg(
|
||||
Arg::new(options::BYTES)
|
||||
|
|
|
@ -12,7 +12,7 @@ use libc::c_long;
|
|||
use uucore::{error::UResult, format_usage};
|
||||
|
||||
const USAGE: &str = "{} [options]";
|
||||
const SUMMARY: &str = "Print the numeric identifier (in hexadecimal) for the current host";
|
||||
const ABOUT: &str = "Print the numeric identifier (in hexadecimal) for the current host";
|
||||
|
||||
// currently rust libc interface doesn't include gethostid
|
||||
extern "C" {
|
||||
|
@ -29,7 +29,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
|||
pub fn uu_app<'a>() -> Command<'a> {
|
||||
Command::new(uucore::util_name())
|
||||
.version(crate_version!())
|
||||
.about(SUMMARY)
|
||||
.about(ABOUT)
|
||||
.override_usage(format_usage(USAGE))
|
||||
.infer_long_args(true)
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ fn get_userlogin() -> Option<String> {
|
|||
}
|
||||
}
|
||||
|
||||
static SUMMARY: &str = "Print user's login name";
|
||||
static ABOUT: &str = "Print user's login name";
|
||||
|
||||
#[uucore::main]
|
||||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||
|
@ -55,6 +55,6 @@ pub fn uu_app<'a>() -> Command<'a> {
|
|||
Command::new(uucore::util_name())
|
||||
.version(crate_version!())
|
||||
.override_usage(uucore::execution_phrase())
|
||||
.about(SUMMARY)
|
||||
.about(ABOUT)
|
||||
.infer_long_args(true)
|
||||
}
|
||||
|
|
|
@ -53,6 +53,9 @@ static CONTEXT_HELP_TEXT: &str = "print any security context of each file (not e
|
|||
#[cfg(feature = "selinux")]
|
||||
static CONTEXT_HELP_TEXT: &str = "print any security context of each file";
|
||||
|
||||
const ABOUT: &str = r#"List directory contents.
|
||||
Ignore files and directories starting with a '.' by default"#;
|
||||
|
||||
const USAGE: &str = "{} [OPTION]... [FILE]...";
|
||||
|
||||
pub mod options {
|
||||
|
@ -898,7 +901,7 @@ pub fn uu_app<'a>() -> Command<'a> {
|
|||
Command::new(uucore::util_name())
|
||||
.version(crate_version!())
|
||||
.override_usage(format_usage(USAGE))
|
||||
.about("List directory contents. Ignore files and directories starting with a '.' by default")
|
||||
.about(ABOUT)
|
||||
.infer_long_args(true)
|
||||
.arg(
|
||||
Arg::new(options::HELP)
|
||||
|
|
|
@ -17,7 +17,7 @@ use uucore::{display::Quotable, InvalidEncodingHandling};
|
|||
|
||||
static NAME: &str = "mkfifo";
|
||||
static USAGE: &str = "{} [OPTION]... NAME...";
|
||||
static SUMMARY: &str = "Create a FIFO with the given name.";
|
||||
static ABOUT: &str = "Create a FIFO with the given name.";
|
||||
|
||||
mod options {
|
||||
pub static MODE: &str = "mode";
|
||||
|
@ -75,7 +75,7 @@ pub fn uu_app<'a>() -> Command<'a> {
|
|||
.name(NAME)
|
||||
.version(crate_version!())
|
||||
.override_usage(format_usage(USAGE))
|
||||
.about(SUMMARY)
|
||||
.about(ABOUT)
|
||||
.infer_long_args(true)
|
||||
.arg(
|
||||
Arg::new(options::MODE)
|
||||
|
|
|
@ -19,6 +19,7 @@ use uucore::{format_usage, InvalidEncodingHandling};
|
|||
mod helper;
|
||||
|
||||
static NAME: &str = "nl";
|
||||
static ABOUT: &str = "number lines of files";
|
||||
static USAGE: &str = "{} [OPTION]... [FILE]...";
|
||||
|
||||
// Settings store options used by nl to produce its output.
|
||||
|
@ -143,6 +144,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
|||
pub fn uu_app<'a>() -> Command<'a> {
|
||||
Command::new(uucore::util_name())
|
||||
.name(NAME)
|
||||
.about(ABOUT)
|
||||
.version(crate_version!())
|
||||
.override_usage(format_usage(USAGE))
|
||||
.infer_long_args(true)
|
||||
|
|
|
@ -22,7 +22,7 @@ use clap::{crate_version, Arg, Command};
|
|||
use std::path::PathBuf;
|
||||
use uucore::{format_usage, InvalidEncodingHandling};
|
||||
|
||||
static ABOUT: &str = "pinky - lightweight finger";
|
||||
static ABOUT: &str = "lightweight finger";
|
||||
const USAGE: &str = "{} [OPTION]... [USER]...";
|
||||
|
||||
mod options {
|
||||
|
|
|
@ -20,8 +20,8 @@ use uucore::{format_usage, InvalidEncodingHandling};
|
|||
|
||||
static NAME: &str = "sum";
|
||||
static USAGE: &str = "{} [OPTION]... [FILE]...";
|
||||
static SUMMARY: &str = "Checksum and count the blocks in a file.\n\
|
||||
With no FILE, or when FILE is -, read standard input.";
|
||||
static ABOUT: &str = r#"Checksum and count the blocks in a file.
|
||||
With no FILE, or when FILE is -, read standard input."#;
|
||||
|
||||
// This can be replaced with usize::div_ceil once it is stabilized.
|
||||
// This implementation approach is optimized for when `b` is a constant,
|
||||
|
@ -156,7 +156,7 @@ pub fn uu_app<'a>() -> Command<'a> {
|
|||
.name(NAME)
|
||||
.version(crate_version!())
|
||||
.override_usage(format_usage(USAGE))
|
||||
.about(SUMMARY)
|
||||
.about(ABOUT)
|
||||
.infer_long_args(true)
|
||||
.arg(
|
||||
Arg::new(options::FILE)
|
||||
|
|
|
@ -26,7 +26,7 @@ use crate::error::TacError;
|
|||
|
||||
static NAME: &str = "tac";
|
||||
static USAGE: &str = "{} [OPTION]... [FILE]...";
|
||||
static SUMMARY: &str = "Write each file to standard output, last line first.";
|
||||
static ABOUT: &str = "Write each file to standard output, last line first.";
|
||||
|
||||
mod options {
|
||||
pub static BEFORE: &str = "before";
|
||||
|
@ -65,7 +65,7 @@ pub fn uu_app<'a>() -> Command<'a> {
|
|||
.name(NAME)
|
||||
.version(crate_version!())
|
||||
.override_usage(format_usage(USAGE))
|
||||
.about(SUMMARY)
|
||||
.about(ABOUT)
|
||||
.infer_long_args(true)
|
||||
.arg(
|
||||
Arg::new(options::BEFORE)
|
||||
|
|
|
@ -14,10 +14,10 @@ use uucore::display::Quotable;
|
|||
use uucore::error::{FromIo, UResult, USimpleError};
|
||||
use uucore::{format_usage, InvalidEncodingHandling};
|
||||
|
||||
static SUMMARY: &str = "Topological sort the strings in FILE.
|
||||
static ABOUT: &str = "Topological sort the strings in FILE.
|
||||
Strings are defined as any sequence of tokens separated by whitespace (tab, space, or newline).
|
||||
If FILE is not passed in, stdin is used instead.";
|
||||
static USAGE: &str = "tsort [OPTIONS] FILE";
|
||||
static USAGE: &str = "{} [OPTIONS] FILE";
|
||||
|
||||
mod options {
|
||||
pub const FILE: &str = "file";
|
||||
|
@ -93,7 +93,7 @@ pub fn uu_app<'a>() -> Command<'a> {
|
|||
Command::new(uucore::util_name())
|
||||
.version(crate_version!())
|
||||
.override_usage(format_usage(USAGE))
|
||||
.about(SUMMARY)
|
||||
.about(ABOUT)
|
||||
.infer_long_args(true)
|
||||
.arg(
|
||||
Arg::new(options::FILE)
|
||||
|
|
|
@ -17,7 +17,8 @@ use uucore::{
|
|||
format_usage,
|
||||
};
|
||||
|
||||
const ABOUT: &str = "Print certain system information. With no OPTION, same as -s.";
|
||||
const ABOUT: &str = r#"Print certain system information.
|
||||
With no OPTION, same as -s."#;
|
||||
const USAGE: &str = "{} [OPTION]...";
|
||||
|
||||
pub mod options {
|
||||
|
|
|
@ -25,8 +25,8 @@ use uucore::{format_usage, InvalidEncodingHandling};
|
|||
|
||||
static NAME: &str = "unexpand";
|
||||
static USAGE: &str = "{} [OPTION]... [FILE]...";
|
||||
static SUMMARY: &str = "Convert blanks in each FILE to tabs, writing to standard output.\n\
|
||||
With no FILE, or when FILE is -, read standard input.";
|
||||
static ABOUT: &str = r#"Convert blanks in each FILE to tabs, writing to standard output.
|
||||
With no FILE, or when FILE is -, read standard input."#;
|
||||
|
||||
const DEFAULT_TABSTOP: usize = 8;
|
||||
|
||||
|
@ -179,7 +179,7 @@ pub fn uu_app<'a>() -> Command<'a> {
|
|||
.name(NAME)
|
||||
.version(crate_version!())
|
||||
.override_usage(format_usage(USAGE))
|
||||
.about(SUMMARY)
|
||||
.about(ABOUT)
|
||||
.infer_long_args(true)
|
||||
.arg(
|
||||
Arg::new(options::FILE)
|
||||
|
|
|
@ -10,9 +10,6 @@
|
|||
use std::borrow::Cow;
|
||||
use std::io::{self, Result, Write};
|
||||
|
||||
#[macro_use]
|
||||
extern crate clap;
|
||||
|
||||
use clap::{Arg, Command};
|
||||
use uucore::error::{UResult, USimpleError};
|
||||
use uucore::format_usage;
|
||||
|
@ -20,6 +17,7 @@ use uucore::format_usage;
|
|||
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||
mod splice;
|
||||
|
||||
const ABOUT: &str = "repeatedly display a line with STRING (or 'y')";
|
||||
const USAGE: &str = "{} [STRING]...";
|
||||
|
||||
// it's possible that using a smaller or larger buffer might provide better performance on some
|
||||
|
@ -50,7 +48,8 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
|||
}
|
||||
|
||||
pub fn uu_app<'a>() -> Command<'a> {
|
||||
command!()
|
||||
Command::new(uucore::util_name())
|
||||
.about(ABOUT)
|
||||
.override_usage(format_usage(USAGE))
|
||||
.arg(Arg::new("STRING").index(1).multiple_occurrences(true))
|
||||
.infer_long_args(true)
|
||||
|
|
Loading…
Reference in a new issue