Skip to content

Commit

Permalink
du: move help strings to markdown file (#4384)
Browse files Browse the repository at this point in the history
  • Loading branch information
papparapa committed Feb 21, 2023
1 parent 9d655bf commit 4e7ae2d
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 21 deletions.
24 changes: 24 additions & 0 deletions src/uu/du/du.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# du

```
du [OPTION]... [FILE]...
du [OPTION]... --files0-from=F
```

Estimate file space usage

## After Help

Display values are in units of the first available SIZE from --block-size,
and the DU_BLOCK_SIZE, BLOCK_SIZE and BLOCKSIZE environment variables.
Otherwise, units default to 1024 bytes (or 512 if POSIXLY_CORRECT is set).

SIZE is an integer and optional unit (example: 10M is 10*1024*1024).
Units are K, M, G, T, P, E, Z, Y (powers of 1024) or KB, MB,... (powers
of 1000).

PATTERN allows some advanced exclusions. For example, the following syntaxes
are supported:
? will match only one character
* will match zero or more characters
{a,b} will match a or b
28 changes: 7 additions & 21 deletions src/uu/du/src/du.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ use uucore::error::FromIo;
use uucore::error::{UError, UResult};
use uucore::parse_glob;
use uucore::parse_size::{parse_size, ParseSizeError};
use uucore::{crash, format_usage, show, show_error, show_warning};
use uucore::{
crash, format_usage, help_about, help_section, help_usage, show, show_error, show_warning,
};
#[cfg(windows)]
use windows_sys::Win32::Foundation::HANDLE;
#[cfg(windows)]
Expand Down Expand Up @@ -73,25 +75,9 @@ mod options {
pub const FILE: &str = "FILE";
}

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.
Otherwise, units default to 1024 bytes (or 512 if POSIXLY_CORRECT is set).
SIZE is an integer and optional unit (example: 10M is 10*1024*1024).
Units are K, M, G, T, P, E, Z, Y (powers of 1024) or KB, MB,... (powers
of 1000).
PATTERN allows some advanced exclusions. For example, the following syntaxes
are supported:
? will match only one character
* will match zero or more characters
{a,b} will match a or b
";
const USAGE: &str = "\
{} [OPTION]... [FILE]...
{} [OPTION]... --files0-from=F";
const ABOUT: &str = help_about!("du.md");
const AFTER_HELP: &str = help_section!("after help", "du.md");
const USAGE: &str = help_usage!("du.md");

// TODO: Support Z & Y (currently limited by size of u64)
const UNITS: [(char, u32); 6] = [('E', 6), ('P', 5), ('T', 4), ('G', 3), ('M', 2), ('K', 1)];
Expand Down Expand Up @@ -705,7 +691,7 @@ pub fn uu_app() -> Command {
Command::new(uucore::util_name())
.version(crate_version!())
.about(ABOUT)
.after_help(LONG_HELP)
.after_help(AFTER_HELP)
.override_usage(format_usage(USAGE))
.infer_long_args(true)
.disable_help_flag(true)
Expand Down

0 comments on commit 4e7ae2d

Please sign in to comment.