# process_killer

Kill processes using a flexible builder pattern.

```rhai
process_killer() -> ProcessKiller
```

The `ProcessKiller` builder allows you to kill processes either by pattern or by PID, with optional recursive killing of child processes.

## Methods

### `.pattern(pattern: &str) -> ProcessKiller`

Set the process name pattern to match. Uses process name matching on your platform (pkill on Unix-like systems, taskkill on Windows).

### `.pid(pid: i64) -> ProcessKiller`

Set the specific process ID (PID) to kill.

### `.recursive(recursive: bool) -> ProcessKiller`

Enable or disable recursive killing of child processes. Default is false.

**Note:** You can specify either a pattern or a PID, but not both. If you don't specify one of them, `.kill()` will return an error.

### `.kill() -> String`

Execute the kill operation. Returns a status message on success.

## Examples

### Kill by process name pattern

```rhai
process_killer()
    .pattern("nginx")
    .kill()?;
print("Nginx processes killed");
```

### Kill by process name with multiple arguments

```rhai
process_killer()
    .pattern("node server.js")
    .kill()?;
```

### Kill a specific process by PID

```rhai
process_killer()
    .pid(1234)
    .kill()?;
print("Process 1234 killed");
```

### Kill a process and all its children

```rhai
let proc = process_get("myapp")?;
process_killer()
    .pid(proc.pid)
    .recursive(true)
    .kill()?;
print("Process tree killed");
```

### Kill by PID recursively

```rhai
process_killer()
    .pid(12345)
    .recursive(true)
    .kill()?;
```
