truncate: move help strings to markdown file

This commit is contained in:
Alexander Kunde 2023-03-02 18:00:31 +01:00
parent b9bca794cc
commit df5ceaaa97
2 changed files with 33 additions and 21 deletions

View file

@ -14,7 +14,7 @@ use std::os::unix::fs::FileTypeExt;
use std::path::Path;
use uucore::display::Quotable;
use uucore::error::{FromIo, UResult, USimpleError, UUsageError};
use uucore::format_usage;
use uucore::{format_usage, help_about, help_section, help_usage};
use uucore::parse_size::{parse_size, ParseSizeError};
#[derive(Debug, Eq, PartialEq)]
@ -73,25 +73,9 @@ impl TruncateMode {
}
}
const ABOUT: &str = "Shrink or extend the size of each file to the specified size.";
const USAGE: &str = "{} [OPTION]... [FILE]...";
const LONG_USAGE: &str = "\
SIZE is an integer with an optional prefix and optional unit.
The available units (K, M, G, T, P, E, Z, and Y) use the following format:
'KB' => 1000 (kilobytes)
'K' => 1024 (kibibytes)
'MB' => 1000*1000 (megabytes)
'M' => 1024*1024 (mebibytes)
'GB' => 1000*1000*1000 (gigabytes)
'G' => 1024*1024*1024 (gibibytes)
SIZE may also be prefixed by one of the following to adjust the size of each
file based on its current size:
'+' => extend by
'-' => reduce by
'<' => at most
'>' => at least
'/' => round down to multiple of
'%' => round up to multiple of";
const ABOUT: &str = help_about!("truncate.md");
const AFTER_HELP: &str = help_section!("after help", "truncate.md");
const USAGE: &str = help_usage!("truncate.md");
pub mod options {
pub static IO_BLOCKS: &str = "io-blocks";
@ -104,7 +88,7 @@ pub mod options {
#[uucore::main]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let matches = uu_app()
.after_help(LONG_USAGE)
.after_help(AFTER_HELP)
.try_get_matches_from(args)
.map_err(|e| {
e.print().expect("Error writing clap::Error");

View file

@ -0,0 +1,28 @@
# truncate
## Usage
```sh
truncate [OPTION]... [FILE]...
```
Shrink or extend the size of each file to the specified size.
## After help
SIZE is an integer with an optional prefix and optional unit.
The available units (K, M, G, T, P, E, Z, and Y) use the following format:
'KB' => 1000 (kilobytes)
'K' => 1024 (kibibytes)
'MB' => 1000*1000 (megabytes)
'M' => 1024*1024 (mebibytes)
'GB' => 1000*1000*1000 (gigabytes)
'G' => 1024*1024*1024 (gibibytes)
SIZE may also be prefixed by one of the following to adjust the size of each
file based on its current size:
'+' => extend by
'-' => reduce by
'<' => at most
'>' => at least
'/' => round down to multiple of
'%' => round up to multiple of