From be1869d58482ed29fb030effd9cabd7899939feb Mon Sep 17 00:00:00 2001 From: Tuomas Tynkkynen Date: Sun, 9 Feb 2025 22:15:53 +0200 Subject: [PATCH] pgrep, pkill: Unify arg lists Most of the process matching arguments are same between pkill and pgrep. Currently pgrep has more complete list of possible arguments (with proper types), so copy over the improvements to pgrep. However, leave arg!()s that are actually not implemented commented out, so it's easier to see what the uutils version actually supports. --- src/uu/pgrep/src/pgrep.rs | 28 ++++++++++++++++----- src/uu/pkill/src/pkill.rs | 53 +++++++++++++++++++-------------------- 2 files changed, 48 insertions(+), 33 deletions(-) diff --git a/src/uu/pgrep/src/pgrep.rs b/src/uu/pgrep/src/pgrep.rs index e59c5cb..eeb016b 100644 --- a/src/uu/pgrep/src/pgrep.rs +++ b/src/uu/pgrep/src/pgrep.rs @@ -293,8 +293,12 @@ pub fn uu_app() -> Command { // arg!(-w --lightweight "list all TID"), arg!(-c --count "count of matching processes"), arg!(-f --full "use full process name to match"), - // arg!(-g --pgroup ... "match listed process group IDs"), - // arg!(-G --group ... "match real group IDs"), + // arg!(-g --pgroup ... "match listed process group IDs") + // .value_delimiter(',') + // .value_parser(clap::value_parser!(u64)), + // arg!(-G --group ... "match real group IDs") + // .value_delimiter(',') + // .value_parser(clap::value_parser!(u64)), arg!(-i --"ignore-case" "match case insensitively"), arg!(-n --newest "select most recently started"), arg!(-o --oldest "select least recently started"), @@ -303,17 +307,29 @@ pub fn uu_app() -> Command { arg!(-P --parent "match only child processes of the given parent") .value_delimiter(',') .value_parser(clap::value_parser!(u64)), - // arg!(-s --session "match session IDs"), + // arg!(-s --session "match session IDs") + // .value_delimiter(',') + // .value_parser(clap::value_parser!(u64)), + // arg!(--signal "signal to send (either number or name)"), arg!(-t --terminal "match by controlling terminal") .value_delimiter(','), - // arg!(-u --euid ... "match by effective IDs"), - // arg!(-U --uid ... "match by real IDs"), + // arg!(-u --euid ... "match by effective IDs") + // .value_delimiter(',') + // .value_parser(clap::value_parser!(u64)), + // arg!(-U --uid ... "match by real IDs") + // .value_delimiter(',') + // .value_parser(clap::value_parser!(u64)), arg!(-x --exact "match exactly with the command name"), // arg!(-F --pidfile "read PIDs from file"), // arg!(-L --logpidfile "fail if PID file is not locked"), arg!(-r --runstates "match runstates [D,S,Z,...]"), + // arg!(-A --"ignore-ancestors" "exclude our ancestors from results"), + // arg!(--cgroup "match by cgroup v2 names") + // .value_delimiter(','), // arg!( --ns "match the processes that belong to the same namespace as "), - // arg!( --nslist ... "list which namespaces will be considered for the --ns option."), + // arg!( --nslist ... "list which namespaces will be considered for the --ns option.") + // .value_delimiter(',') + // .value_parser(["ipc", "mnt", "net", "pid", "user", "uts"]), ]) .arg( Arg::new("pattern") diff --git a/src/uu/pkill/src/pkill.rs b/src/uu/pkill/src/pkill.rs index 9d3fb78..b534af4 100644 --- a/src/uu/pkill/src/pkill.rs +++ b/src/uu/pkill/src/pkill.rs @@ -347,16 +347,16 @@ pub fn uu_app() -> Command { .args([ // arg!(- "signal to send (either number or name)"), arg!(-H --"require-handler" "match only if signal handler is present"), - arg!(-q --queue "integer value to be sent with the signal"), + // arg!(-q --queue "integer value to be sent with the signal"), arg!(-e --echo "display what is killed"), arg!(-c --count "count of matching processes"), arg!(-f --full "use full process name to match"), - arg!(-g --pgroup "match listed process group IDs") - .value_delimiter(',') - .value_parser(clap::value_parser!(u64)), - arg!(-G --group "match real group IDs") - .value_delimiter(',') - .value_parser(clap::value_parser!(u64)), + // arg!(-g --pgroup "match listed process group IDs") + // .value_delimiter(',') + // .value_parser(clap::value_parser!(u64)), + // arg!(-G --group "match real group IDs") + // .value_delimiter(',') + // .value_parser(clap::value_parser!(u64)), arg!(-i --"ignore-case" "match case insensitively"), arg!(-n --newest "select most recently started"), arg!(-o --oldest "select least recently started"), @@ -365,29 +365,28 @@ pub fn uu_app() -> Command { arg!(-P --parent "match only child processes of the given parent") .value_delimiter(',') .value_parser(clap::value_parser!(u64)), - arg!(-s --session "match session IDs") - .value_delimiter(',') - .value_parser(clap::value_parser!(u64)), + // arg!(-s --session "match session IDs") + // .value_delimiter(',') + // .value_parser(clap::value_parser!(u64)), arg!(--signal "signal to send (either number or name)"), - arg!(-t --terminal "match by controlling terminal") - .value_delimiter(','), - arg!(-u --euid "match by effective IDs") - .value_delimiter(',') - .value_parser(clap::value_parser!(u64)), - arg!(-U --uid "match by real IDs") - .value_delimiter(',') - .value_parser(clap::value_parser!(u64)), + arg!(-t --terminal "match by controlling terminal").value_delimiter(','), + // arg!(-u --euid "match by effective IDs") + // .value_delimiter(',') + // .value_parser(clap::value_parser!(u64)), + // arg!(-U --uid "match by real IDs") + // .value_delimiter(',') + // .value_parser(clap::value_parser!(u64)), arg!(-x --exact "match exactly with the command name"), - arg!(-F --pidfile "read PIDs from file"), - arg!(-L --logpidfile "fail if PID file is not locked"), + // arg!(-F --pidfile "read PIDs from file"), + // arg!(-L --logpidfile "fail if PID file is not locked"), arg!(-r --runstates "match runstates [D,S,Z,...]"), - arg!(-A --"ignore-ancestors" "exclude our ancestors from results"), - arg!(--cgroup "match by cgroup v2 names") - .value_delimiter(','), - arg!(--ns "match the processes that belong to the same namespace as "), - arg!(--nslist "list which namespaces will be considered for the --ns option.") - .value_delimiter(',') - .value_parser(["ipc", "mnt", "net", "pid", "user", "uts"]), + // arg!(-A --"ignore-ancestors" "exclude our ancestors from results"), + // arg!(--cgroup "match by cgroup v2 names") + // .value_delimiter(','), + // arg!(--ns "match the processes that belong to the same namespace as "), + // arg!(--nslist "list which namespaces will be considered for the --ns option.") + // .value_delimiter(',') + // .value_parser(["ipc", "mnt", "net", "pid", "user", "uts"]), ]) .arg( Arg::new("pattern")