mirror of
https://github.com/uutils/procps.git
synced 2026-05-06 06:06:43 -04:00
ps: improve the parameter output of the ps command
This commit is contained in:
@@ -71,7 +71,7 @@ pub struct ProcessSelectionSettings {
|
|||||||
impl ProcessSelectionSettings {
|
impl ProcessSelectionSettings {
|
||||||
pub fn from_matches(matches: &ArgMatches) -> Self {
|
pub fn from_matches(matches: &ArgMatches) -> Self {
|
||||||
Self {
|
Self {
|
||||||
select_all: matches.get_flag("A"),
|
select_all: matches.get_flag("A") || matches.get_flag("e"),
|
||||||
select_non_session_leaders_with_tty: matches.get_flag("a"),
|
select_non_session_leaders_with_tty: matches.get_flag("a"),
|
||||||
select_non_session_leaders: matches.get_flag("d"),
|
select_non_session_leaders: matches.get_flag("d"),
|
||||||
dont_require_tty: matches.get_flag("x"),
|
dont_require_tty: matches.get_flag("x"),
|
||||||
|
|||||||
+4
-1
@@ -202,7 +202,10 @@ pub fn uu_app() -> Command {
|
|||||||
Arg::new("A")
|
Arg::new("A")
|
||||||
.short('A')
|
.short('A')
|
||||||
.help("all processes")
|
.help("all processes")
|
||||||
.visible_short_alias('e')
|
.action(ArgAction::SetTrue),
|
||||||
|
Arg::new("e")
|
||||||
|
.short('e')
|
||||||
|
.help("Select all processes. Identical to -A")
|
||||||
.action(ArgAction::SetTrue),
|
.action(ArgAction::SetTrue),
|
||||||
Arg::new("a")
|
Arg::new("a")
|
||||||
.short('a')
|
.short('a')
|
||||||
|
|||||||
@@ -13,9 +13,24 @@ use uucore::process::geteuid;
|
|||||||
#[test]
|
#[test]
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
fn test_select_all_processes() {
|
fn test_select_all_processes() {
|
||||||
for arg in ["-A", "-e"] {
|
let expected_headers = ["PID", "TTY", "TIME", "CMD"];
|
||||||
// TODO ensure the output format is correct
|
|
||||||
new_ucmd!().arg(arg).succeeds();
|
let args_sets = vec![vec!["-A"], vec!["-e"], vec!["-A", "-e"]];
|
||||||
|
for args in args_sets {
|
||||||
|
let result = new_ucmd!().args(&args).succeeds();
|
||||||
|
let lines: Vec<&str> = result.stdout_str().lines().collect();
|
||||||
|
|
||||||
|
assert!(
|
||||||
|
lines.len() >= 2,
|
||||||
|
"expected at least a header and one process row"
|
||||||
|
);
|
||||||
|
|
||||||
|
let headers: Vec<&str> = lines[0].split_whitespace().collect();
|
||||||
|
assert_eq!(
|
||||||
|
headers, expected_headers,
|
||||||
|
"unexpected header for args: {:?}",
|
||||||
|
args
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user