1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-29 03:57:44 +00:00

Merge pull request #4585 from piotrkwiecinski/id-move-string-to-md-file

id: move help strings to a markdown file
This commit is contained in:
Daniel Hofstetter 2023-03-23 13:46:21 +01:00 committed by GitHub
commit 2db88f1f26
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 16 deletions

18
src/uu/id/id.md Normal file
View file

@ -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.

View file

@ -45,7 +45,7 @@ use uucore::error::{set_exit_code, USimpleError};
pub use uucore::libc; pub use uucore::libc;
use uucore::libc::{getlogin, uid_t}; use uucore::libc::{getlogin, uid_t};
use uucore::process::{getegid, geteuid, getgid, getuid}; 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 { macro_rules! cstr2cow {
($v:expr) => { ($v:expr) => {
@ -53,9 +53,9 @@ macro_rules! cstr2cow {
}; };
} }
static ABOUT: &str = "Print user and group information for each specified USER, const ABOUT: &str = help_about!("id.md");
or (when USER omitted) for the current user."; const USAGE: &str = help_usage!("id.md");
const USAGE: &str = "{} [OPTION]... [USER]..."; const AFTER_HELP: &str = help_section!("after help", "id.md");
#[cfg(not(feature = "selinux"))] #[cfg(not(feature = "selinux"))]
static CONTEXT_HELP_TEXT: &str = "print only the security context of the process (not enabled)"; 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"; 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 { struct Ids {
uid: u32, // user id uid: u32, // user id
gid: u32, // group id gid: u32, // group id
@ -121,9 +112,7 @@ struct State {
#[uucore::main] #[uucore::main]
pub fn uumain(args: impl uucore::Args) -> UResult<()> { pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let matches = uu_app() let matches = uu_app().after_help(AFTER_HELP).try_get_matches_from(args)?;
.after_help(get_description())
.try_get_matches_from(args)?;
let users: Vec<String> = matches let users: Vec<String> = matches
.get_many::<String>(options::ARG_USERS) .get_many::<String>(options::ARG_USERS)