1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 11:37:44 +00:00

Use help_about! & adapt help files for its usage

This commit is contained in:
Daniel Hofstetter 2023-02-17 16:40:22 +01:00
parent 2c027a9312
commit dcc7c4ed7b
16 changed files with 32 additions and 47 deletions

View file

@ -1,12 +1,9 @@
# base32
## Usage
```
base32 [OPTION]... [FILE]
```
## About
encode/decode data and print to standard output
With no FILE, or when FILE is -, read standard input.

View file

@ -8,11 +8,11 @@
use std::io::{stdin, Read};
use clap::Command;
use uucore::{encoding::Format, error::UResult, help_section, help_usage};
use uucore::{encoding::Format, error::UResult, help_about, help_usage};
pub mod base_common;
const ABOUT: &str = help_section!("about", "base32.md");
const ABOUT: &str = help_about!("base32.md");
const USAGE: &str = help_usage!("base32.md");
#[uucore::main]

View file

@ -1,12 +1,9 @@
# base64
## Usage
```
base64 [OPTION]... [FILE]
```
## About
encode/decode data and print to standard output
With no FILE, or when FILE is -, read standard input.

View file

@ -9,11 +9,11 @@
use uu_base32::base_common;
pub use uu_base32::uu_app;
use uucore::{encoding::Format, error::UResult, help_section, help_usage};
use uucore::{encoding::Format, error::UResult, help_about, help_usage};
use std::io::{stdin, Read};
const ABOUT: &str = help_section!("about", "base64.md");
const ABOUT: &str = help_about!("base64.md");
const USAGE: &str = help_usage!("base64.md");
#[uucore::main]

View file

@ -1,11 +1,8 @@
# cat
## Usage
```
cat [OPTION]... [FILE]...
```
## About
Concatenate FILE(s), or standard input, to standard output
With no FILE, or when FILE is -, read standard input.

View file

@ -33,10 +33,10 @@ use std::net::Shutdown;
use std::os::unix::fs::FileTypeExt;
#[cfg(unix)]
use std::os::unix::net::UnixStream;
use uucore::{format_usage, help_section, help_usage};
use uucore::{format_usage, help_about, help_usage};
const USAGE: &str = help_usage!("cat.md");
const ABOUT: &str = help_section!("about", "cat.md");
const ABOUT: &str = help_about!("cat.md");
#[derive(Error, Debug)]
enum CatError {

View file

@ -1,12 +1,9 @@
# cp
## Usage
```
cp [OPTION]... [-T] SOURCE DEST
cp [OPTION]... SOURCE... DIRECTORY
cp [OPTION]... -t DIRECTORY SOURCE...
```
## About
Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY.

View file

@ -40,7 +40,7 @@ use uucore::error::{set_exit_code, UClapError, UError, UResult, UUsageError};
use uucore::fs::{
canonicalize, paths_refer_to_same_file, FileInformation, MissingHandling, ResolveMode,
};
use uucore::{crash, format_usage, help_section, help_usage, prompt_yes, show_error, show_warning};
use uucore::{crash, format_usage, help_about, help_usage, prompt_yes, show_error, show_warning};
use crate::copydir::copy_directory;
@ -228,11 +228,11 @@ pub struct Options {
progress_bar: bool,
}
const ABOUT: &str = help_section!("about", "cp.md");
static EXIT_ERR: i32 = 1;
const ABOUT: &str = help_about!("cp.md");
const USAGE: &str = help_usage!("cp.md");
static EXIT_ERR: i32 = 1;
// Argument constants
mod options {
pub const ARCHIVE: &str = "archive";

View file

@ -1,7 +1,11 @@
<!-- spell-checker:ignore convs iseek oseek -->
# dd
## About
```
dd [OPERAND]...
dd OPTION
```
Copy, and optionally convert, a file system resource
## After Help

View file

@ -39,11 +39,11 @@ use clap::{crate_version, Arg, Command};
use gcd::Gcd;
use uucore::display::Quotable;
use uucore::error::{FromIo, UResult};
use uucore::help_section;
use uucore::show_error;
use uucore::{format_usage, help_about, help_section, help_usage, show_error};
const ABOUT: &str = help_section!("about", "dd.md");
const ABOUT: &str = help_about!("dd.md");
const AFTER_HELP: &str = help_section!("after help", "dd.md");
const USAGE: &str = help_usage!("dd.md");
const BUF_INIT_BYTE: u8 = 0xDD;
/// Final settings after parsing
@ -832,6 +832,7 @@ pub fn uu_app() -> Command {
Command::new(uucore::util_name())
.version(crate_version!())
.about(ABOUT)
.override_usage(format_usage(USAGE))
.after_help(AFTER_HELP)
.infer_long_args(true)
.arg(Arg::new(options::OPERANDS).num_args(1..))

View file

@ -1,15 +1,12 @@
# expr
## About
Print the value of `EXPRESSION` to standard output
## Usage
```
expr [EXPRESSION]
expr [OPTIONS]
```
Print the value of `EXPRESSION` to standard output
## After help
Print the value of `EXPRESSION` to standard output. A blank line below
@ -58,4 +55,4 @@ Environment variables:
- `EXPR_DEBUG_TOKENS=1`: dump expression's tokens
- `EXPR_DEBUG_RPN=1`: dump expression represented in reverse polish notation
- `EXPR_DEBUG_SYA_STEP=1`: dump each parser step
- `EXPR_DEBUG_AST=1`: dump expression represented abstract syntax tree
- `EXPR_DEBUG_AST=1`: dump expression represented abstract syntax tree

View file

@ -8,7 +8,7 @@
use clap::{crate_version, Arg, ArgAction, Command};
use uucore::{
error::{UResult, USimpleError},
format_usage, help_section, help_usage,
format_usage, help_about, help_section, help_usage,
};
mod syntax_tree;
@ -23,7 +23,7 @@ mod options {
pub fn uu_app() -> Command {
Command::new(uucore::util_name())
.version(crate_version!())
.about(help_section!("about", "expr.md"))
.about(help_about!("expr.md"))
.override_usage(format_usage(help_usage!("expr.md")))
.after_help(help_section!("after help", "expr.md"))
.infer_long_args(true)

View file

@ -1,13 +1,10 @@
<!-- spell-checker:ignore N'th M'th -->
# numfmt
## Usage
```
numfmt [OPTION]... [NUMBER]...
```
## About
Convert numbers from/to human-readable strings
## After Help

View file

@ -14,16 +14,15 @@ use std::io::{BufRead, Write};
use units::{IEC_BASES, SI_BASES};
use uucore::display::Quotable;
use uucore::error::UResult;
use uucore::format_usage;
use uucore::ranges::Range;
use uucore::{help_section, help_usage};
use uucore::{format_usage, help_about, help_section, help_usage};
pub mod errors;
pub mod format;
pub mod options;
mod units;
const ABOUT: &str = help_section!("about", "numfmt.md");
const ABOUT: &str = help_about!("numfmt.md");
const AFTER_HELP: &str = help_section!("after help", "numfmt.md");
const USAGE: &str = help_usage!("numfmt.md");

View file

@ -13,7 +13,9 @@ use uucore::fsext::{
pretty_filetype, pretty_fstype, pretty_time, read_fs_list, statfs, BirthTime, FsMeta,
};
use uucore::libc::mode_t;
use uucore::{entries, format_usage, help_section, help_usage, show_error, show_warning};
use uucore::{
entries, format_usage, help_about, help_section, help_usage, show_error, show_warning,
};
use clap::{crate_version, Arg, ArgAction, ArgMatches, Command};
use std::borrow::Cow;
@ -24,7 +26,7 @@ use std::os::unix::fs::{FileTypeExt, MetadataExt};
use std::os::unix::prelude::OsStrExt;
use std::path::Path;
const ABOUT: &str = help_section!("about", "stat.md");
const ABOUT: &str = help_about!("stat.md");
const USAGE: &str = help_usage!("stat.md");
const LONG_USAGE: &str = help_section!("long usage", "stat.md");

View file

@ -1,14 +1,11 @@
# stat
## About
Display file or file system status.
## Usage
```
stat [OPTION]... FILE...
```
Display file or file system status.
## Long Usage
The valid format sequences for files (without `--file-system`):