pidof: Implemented -o (#123)

* pidof: Implemented `-o`

This commit implemented two usage of `-o` which are already implemented in GNU's implementation, but not in ours.

```shell
❯ cargo run pidof zsh
116473 116472 116401 116391

❯ cargo run pidof -o116473,116472 zsh
116401 116391

❯ cargo run pidof -o116473 -o116472 zsh
116401 116391
```

And the GNU's implementation:

```shell
❯ pidof zsh
116473 116472 116401 116391

❯ pidof -o116473,116472 zsh
116401 116391

❯ pidof -o116473 -o116472 zsh
116401 116391
```

* pidof: Add test for `-q` flag.

* pidof: Simplify tests.
This commit is contained in:
Krysztal Huang
2024-07-16 13:52:46 +08:00
committed by GitHub
parent bfe7672b5e
commit ed35512f8a
2 changed files with 7 additions and 0 deletions
+1
View File
@@ -137,6 +137,7 @@ pub fn uu_app() -> Command {
Arg::new("o")
.short('o')
.help("Omit results with a given PID")
.value_delimiter(',')
.action(ArgAction::Append)
.value_parser(clap::value_parser!(usize))
.value_name("omitpid"),
+6
View File
@@ -33,3 +33,9 @@ fn test_no_program() {
fn test_no_pid_found() {
new_ucmd!().arg("NO_THIS_PROGRAM").fails().code_is(1);
}
#[test]
#[cfg(target_os = "linux")]
fn test_quiet() {
new_ucmd!().arg("kthreadd").arg("-q").succeeds().no_output();
}