diff --git a/src/uu/truncate/src/truncate.rs b/src/uu/truncate/src/truncate.rs index 090865313..f050b52b4 100644 --- a/src/uu/truncate/src/truncate.rs +++ b/src/uu/truncate/src/truncate.rs @@ -14,8 +14,8 @@ 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::parse_size::{parse_size, ParseSizeError}; +use uucore::{format_usage, help_about, help_section, help_usage}; #[derive(Debug, Eq, PartialEq)] enum TruncateMode { @@ -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"); diff --git a/src/uu/truncate/truncate.md b/src/uu/truncate/truncate.md new file mode 100644 index 000000000..841c4b16c --- /dev/null +++ b/src/uu/truncate/truncate.md @@ -0,0 +1,25 @@ +# truncate + +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 \ No newline at end of file