Add help argument

This commit is contained in:
aNNiMON 2024-07-23 19:54:41 +03:00
parent d7d723b549
commit 9583c22b2c

View File

@ -13,6 +13,7 @@ enum Mode {
Single(String),
TerminateByPid(u32),
TerminateByName(String),
Help,
}
// pkill => all unique processed, excl. svchost
@ -88,6 +89,18 @@ fn main() -> ExitCode {
ExitCode::FAILURE
}
}
Mode::Help => {
let lines = [
"pkill => all unique processed, excl. system\n",
"pkill <name> => filtered processes by name or it's part\n",
"pkill --all => all processes, incl. system\n",
"pkill --pid <name> => PID of the first occurence\n",
"pkill --kill <PID>/<name> => terminate process by its PID or name\n",
"pkill --help => print help\n",
];
println!("{}", lines.concat());
ExitCode::SUCCESS
}
}
}
@ -96,6 +109,7 @@ fn parse_mode() -> Mode {
let mut iter = env::args().skip(1).into_iter();
while let Some(el) = iter.next() {
match el.as_str() {
"--help" => mode = Mode::Help,
"--all" => {
mode = Mode::All;
}