From 59c210d0f9c69282f25691d15354a4b8f43fd11f Mon Sep 17 00:00:00 2001 From: Miles Liu Date: Wed, 29 Mar 2023 18:07:33 +0800 Subject: [PATCH] uniq: move help strings to markdown file --- src/uu/uniq/src/uniq.rs | 14 +++++--------- src/uu/uniq/uniq.md | 15 +++++++++++++++ 2 files changed, 20 insertions(+), 9 deletions(-) create mode 100644 src/uu/uniq/uniq.md diff --git a/src/uu/uniq/src/uniq.rs b/src/uu/uniq/src/uniq.rs index cd4d728d9..16b4ab2c4 100644 --- a/src/uu/uniq/src/uniq.rs +++ b/src/uu/uniq/src/uniq.rs @@ -12,15 +12,11 @@ use std::path::Path; use std::str::FromStr; 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}; -const ABOUT: &str = "Report or omit repeated lines."; -const USAGE: &str = "{} [OPTION]... [INPUT [OUTPUT]]..."; -const LONG_USAGE: &str = "\ - Filter adjacent matching lines from INPUT (or standard input),\n\ - writing to OUTPUT (or standard output).\n\n\ - Note: 'uniq' does not detect repeated lines unless they are adjacent.\n\ - You may want to sort the input first, or use 'sort -u' without 'uniq'."; +const ABOUT: &str = help_about!("uniq.md"); +const USAGE: &str = help_usage!("uniq.md"); +const AFTER_HELP: &str = help_section!("after help", "uniq.md"); pub mod options { pub static ALL_REPEATED: &str = "all-repeated"; @@ -247,7 +243,7 @@ fn opt_parsed(opt_name: &str, matches: &ArgMatches) -> UResult UResult<()> { - let matches = uu_app().after_help(LONG_USAGE).try_get_matches_from(args)?; + let matches = uu_app().after_help(AFTER_HELP).try_get_matches_from(args)?; let files: Vec = matches .get_many::(ARG_FILES) diff --git a/src/uu/uniq/uniq.md b/src/uu/uniq/uniq.md new file mode 100644 index 000000000..dea57081b --- /dev/null +++ b/src/uu/uniq/uniq.md @@ -0,0 +1,15 @@ +# uniq + +``` +uniq [OPTION]... [INPUT [OUTPUT]]... +``` + +Report or omit repeated lines. + +## After help + +Filter adjacent matching lines from `INPUT` (or standard input), +writing to `OUTPUT` (or standard output). + +Note: `uniq` does not detect repeated lines unless they are adjacent. +You may want to sort the input first, or use `sort -u` without `uniq`.