Skip to content

Commit

Permalink
Add more consistency in the --help output and declarations
Browse files Browse the repository at this point in the history
  • Loading branch information
sylvestre committed Aug 4, 2022
1 parent e199152 commit d7765e0
Show file tree
Hide file tree
Showing 27 changed files with 58 additions and 52 deletions.
1 change: 1 addition & 0 deletions src/uu/base32/src/base32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/uu/base64/src/base64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/uu/basename/src/basename.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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...";
Expand Down Expand Up @@ -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(
Expand Down
1 change: 1 addition & 0 deletions src/uu/basenc/src/basenc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/uu/cat/src/cat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions src/uu/cksum/src/cksum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions src/uu/csplit/src/csplit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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...";

Expand Down Expand Up @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions src/uu/cut/src/cut.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions src/uu/dircolors/src/dircolors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions src/uu/du/src/du.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions src/uu/echo/src/echo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions src/uu/env/src/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 1 addition & 3 deletions src/uu/expr/src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
6 changes: 3 additions & 3 deletions src/uu/factor/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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))
}
4 changes: 2 additions & 2 deletions src/uu/fold/src/fold.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions src/uu/hostid/src/hostid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand All @@ -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)
}
Expand Down
4 changes: 2 additions & 2 deletions src/uu/logname/src/logname.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<()> {
Expand All @@ -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)
}
5 changes: 4 additions & 1 deletion src/uu/ls/src/ls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions src/uu/mkfifo/src/mkfifo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions src/uu/nl/src/nl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/uu/pinky/src/pinky.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions src/uu/sum/src/sum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions src/uu/tac/src/tac.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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)
Expand Down
Loading

0 comments on commit d7765e0

Please sign in to comment.