From df5ceaaa97e4e291a31b1ab7645eaef17566777d Mon Sep 17 00:00:00 2001 From: Alexander Kunde Date: Thu, 2 Mar 2023 18:00:31 +0100 Subject: [PATCH 1/4] truncate: move help strings to markdown file --- src/uu/truncate/src/truncate.rs | 26 +++++--------------------- src/uu/truncate/truncate.md | 28 ++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 21 deletions(-) create mode 100644 src/uu/truncate/truncate.md diff --git a/src/uu/truncate/src/truncate.rs b/src/uu/truncate/src/truncate.rs index 090865313..c71f5079b 100644 --- a/src/uu/truncate/src/truncate.rs +++ b/src/uu/truncate/src/truncate.rs @@ -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"); diff --git a/src/uu/truncate/truncate.md b/src/uu/truncate/truncate.md new file mode 100644 index 000000000..64ab4e019 --- /dev/null +++ b/src/uu/truncate/truncate.md @@ -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 \ No newline at end of file From b73d5206f502a46d13dc1d51e1907547d2a2a862 Mon Sep 17 00:00:00 2001 From: Alexander Kunde Date: Thu, 2 Mar 2023 18:18:40 +0100 Subject: [PATCH 2/4] remove redundant line in markdown --- src/uu/truncate/truncate.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/uu/truncate/truncate.md b/src/uu/truncate/truncate.md index 64ab4e019..36e71e999 100644 --- a/src/uu/truncate/truncate.md +++ b/src/uu/truncate/truncate.md @@ -1,7 +1,5 @@ # truncate -## Usage - ```sh truncate [OPTION]... [FILE]... ``` From 73bb60d72490cefbf8926ca170a83720dd13bacd Mon Sep 17 00:00:00 2001 From: Alexander Kunde Date: Thu, 2 Mar 2023 18:56:08 +0100 Subject: [PATCH 3/4] cargo fmt --- src/uu/truncate/src/truncate.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/uu/truncate/src/truncate.rs b/src/uu/truncate/src/truncate.rs index c71f5079b..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, help_about, help_section, help_usage}; use uucore::parse_size::{parse_size, ParseSizeError}; +use uucore::{format_usage, help_about, help_section, help_usage}; #[derive(Debug, Eq, PartialEq)] enum TruncateMode { From 53d3d4d616d81140923d9ce74cd99f1862cd16c7 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Fri, 3 Mar 2023 13:12:49 +0100 Subject: [PATCH 4/4] remove the sh in the syntax --- src/uu/truncate/truncate.md | 1 - 1 file changed, 1 deletion(-) diff --git a/src/uu/truncate/truncate.md b/src/uu/truncate/truncate.md index 36e71e999..841c4b16c 100644 --- a/src/uu/truncate/truncate.md +++ b/src/uu/truncate/truncate.md @@ -1,6 +1,5 @@ # truncate -```sh truncate [OPTION]... [FILE]... ```