From 1d58362e1a140c971788a9d9ed95097dd0b36b53 Mon Sep 17 00:00:00 2001 From: Miles Liu Date: Tue, 21 Mar 2023 13:38:20 +0800 Subject: [PATCH] factor: move help strings to markdown file --- src/uu/factor/factor.md | 8 ++++++++ src/uu/factor/src/cli.rs | 7 ++++--- 2 files changed, 12 insertions(+), 3 deletions(-) create mode 100644 src/uu/factor/factor.md diff --git a/src/uu/factor/factor.md b/src/uu/factor/factor.md new file mode 100644 index 00000000000..b5bec6039b8 --- /dev/null +++ b/src/uu/factor/factor.md @@ -0,0 +1,8 @@ +# factor + +``` +factor [NUMBER]... +``` + +Print the prime factors of the given NUMBER(s). +If none are specified, read from standard input. diff --git a/src/uu/factor/src/cli.rs b/src/uu/factor/src/cli.rs index 0b50599aef7..956b6aa9f0e 100644 --- a/src/uu/factor/src/cli.rs +++ b/src/uu/factor/src/cli.rs @@ -16,15 +16,15 @@ use clap::{crate_version, Arg, ArgAction, Command}; pub use factor::*; use uucore::display::Quotable; use uucore::error::UResult; -use uucore::{show_error, show_warning}; +use uucore::{format_usage, help_about, help_usage, show_error, show_warning}; mod miller_rabin; pub mod numeric; mod rho; pub mod table; -static ABOUT: &str = r#"Print the prime factors of the given NUMBER(s). -If none are specified, read from standard input."#; +const ABOUT: &str = help_about!("factor.md"); +const USAGE: &str = help_usage!("factor.md"); mod options { pub static NUMBER: &str = "NUMBER"; @@ -84,6 +84,7 @@ pub fn uu_app() -> Command { Command::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) + .override_usage(format_usage(USAGE)) .infer_long_args(true) .arg(Arg::new(options::NUMBER).action(ArgAction::Append)) }