From 186c85522ef7022b3b9261f5024feecd8c59a9f4 Mon Sep 17 00:00:00 2001 From: Piotr Kwiecinski Date: Thu, 23 Mar 2023 11:16:03 +0100 Subject: [PATCH] id: move help strings to a markdown file --- src/uu/id/id.md | 18 ++++++++++++++++++ src/uu/id/src/id.rs | 21 +++++---------------- 2 files changed, 23 insertions(+), 16 deletions(-) create mode 100644 src/uu/id/id.md diff --git a/src/uu/id/id.md b/src/uu/id/id.md new file mode 100644 index 000000000..bb7330314 --- /dev/null +++ b/src/uu/id/id.md @@ -0,0 +1,18 @@ +# id + +``` +id [OPTION]... [USER]... +``` + +Print user and group information for each specified `USER`, +or (when `USER` omitted) for the current user. + +## After help + +The id utility displays the user and group names and numeric IDs, of the +calling process, to the standard output. If the real and effective IDs are +different, both are displayed, otherwise only the real ID is displayed. + +If a user (login name or user ID) is specified, the user and group IDs of +that user are displayed. In this case, the real and effective IDs are +assumed to be the same. diff --git a/src/uu/id/src/id.rs b/src/uu/id/src/id.rs index 9aa6e2f31..4a80099ad 100644 --- a/src/uu/id/src/id.rs +++ b/src/uu/id/src/id.rs @@ -45,7 +45,7 @@ use uucore::error::{set_exit_code, USimpleError}; pub use uucore::libc; use uucore::libc::{getlogin, uid_t}; use uucore::process::{getegid, geteuid, getgid, getuid}; -use uucore::{format_usage, show_error}; +use uucore::{format_usage, help_about, help_section, help_usage, show_error}; macro_rules! cstr2cow { ($v:expr) => { @@ -53,9 +53,9 @@ macro_rules! cstr2cow { }; } -static ABOUT: &str = "Print user and group information for each specified USER, -or (when USER omitted) for the current user."; -const USAGE: &str = "{} [OPTION]... [USER]..."; +const ABOUT: &str = help_about!("id.md"); +const USAGE: &str = help_usage!("id.md"); +const AFTER_HELP: &str = help_section!("after help", "id.md"); #[cfg(not(feature = "selinux"))] static CONTEXT_HELP_TEXT: &str = "print only the security context of the process (not enabled)"; @@ -76,15 +76,6 @@ mod options { pub const ARG_USERS: &str = "USER"; } -fn get_description() -> &'static str { - "The id utility displays the user and group names and numeric IDs, of the \ - calling process, to the standard output. If the real and effective IDs are \ - different, both are displayed, otherwise only the real ID is displayed.\n\n\ - If a user (login name or user ID) is specified, the user and group IDs of \ - that user are displayed. In this case, the real and effective IDs are \ - assumed to be the same." -} - struct Ids { uid: u32, // user id gid: u32, // group id @@ -121,9 +112,7 @@ struct State { #[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { - let matches = uu_app() - .after_help(get_description()) - .try_get_matches_from(args)?; + let matches = uu_app().after_help(AFTER_HELP).try_get_matches_from(args)?; let users: Vec = matches .get_many::(options::ARG_USERS)