# 🛡️ portslay — port-based process killer (Linux)

[![Crates.io](https://img.shields.io/crates/v/portslay.svg)](https://crates.io/crates/portslay)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Build Status](https://github.com/burakzaferozcan/portslay/actions/workflows/ci.yml/badge.svg)](https://github.com/burakzaferozcan/portslay/actions)

A lightweight CLI tool written in Rust, designed to identify and terminate processes occupying specific ports on Linux systems. No more manual `lsof -i :PORT` followed by `kill -9 PID`.

## ✨ Features

- **Interactive Selection**: If multiple processes are found, choose which one to kill.
- **Fast & Lightweight**: Written in Rust for maximum performance.
- **Safe by Default**: Asks for confirmation before killing a single process.
- **Flexible**: Supports SIGTERM (default) and SIGKILL (force).
- **List Mode**: Check port status without taking any action.

## 🛠 Prerequisites

- **Linux OS**: Relies on Linux-specific process management.
- **lsof**: Must be installed on your system.
- **Rust**: Only if you are building from source.

## 🚀 Installation

### Using Cargo (Recommended)

If you have Rust installed, you can install `portslay` directly from [crates.io](https://crates.io/crates/portslay):

```bash
cargo install portslay
```

### From Source

```bash
git clone https://github.com/burakzaferozcan/portslay.git
cd portslay
cargo build --release
# The binary will be at ./target/release/portslay
```

## 📖 Usage

### Basic Usage (Interactive)

Identify processes on a port and choose what to do:
```bash
portslay 3000
```
- If one process is found: Asks for confirmation.
- If multiple processes are found: Shows a menu to select specific PIDs or kill all.

### Force Kill (`--force`)

By default, `portslay` sends `SIGTERM` (15). Use `-f` or `--force` to send `SIGKILL` (9):
```bash
portslay 3000 --force
```

### Non-Interactive Kill All (`--all`)

Immediately terminate all processes listening on the specified port:
```bash
portslay 3000 --all
```

### List Only (`--list`)

Just display the processes without any kill prompts:
```bash
portslay 3000 --list
```

## 📜 License

This project is licensed under the MIT License. See the [LICENSE](https://github.com/burakzaferozcan/portslay/blob/main/LICENSE) file for details.
