kport 2.0.0__tar.gz → 2.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,10 +1,10 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: kport
3
- Version: 2.0.0
3
+ Version: 2.1.0
4
4
  Summary: A cross-platform command-line tool to inspect and kill processes using specific ports
5
5
  Home-page: https://github.com/farman20ali/port-killer
6
- Author: Farman Ali (Alien)
7
- Author-email: farman20ali@example.com
6
+ Author: Farman Ali
7
+ Author-email: farman20ali@gmail.com
8
8
  Project-URL: Bug Reports, https://github.com/farman20ali/port-killer/issues
9
9
  Project-URL: Source, https://github.com/farman20ali/port-killer
10
10
  Keywords: port,kill,process,network,cross-platform,cli
@@ -42,16 +42,24 @@ Dynamic: summary
42
42
 
43
43
  # 🔪 kport - Cross-Platform Port Inspector and Killer
44
44
 
45
+ [![Version](https://img.shields.io/badge/version-1.0.0-blue.svg)](https://github.com/farman20ali/port-killer)
46
+ [![Python](https://img.shields.io/badge/python-3.6+-blue.svg)](https://www.python.org/downloads/)
47
+ [![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
48
+ [![Platform](https://img.shields.io/badge/platform-Windows%20%7C%20Linux%20%7C%20macOS-lightgrey.svg)](https://github.com/farman20ali/port-killer)
49
+
45
50
  A simple, powerful command-line tool to inspect and kill processes using specific ports on Windows, Linux, and macOS.
46
51
 
47
52
  ## ✨ Features
48
53
 
49
54
  - 🔍 **Inspect ports** - Find which process is using a specific port
55
+ - 🔎 **Inspect multiple ports** - Check multiple ports at once
56
+ - 🔍 **Inspect port range** - Scan a range of ports (e.g., 3000-3010)
50
57
  - 🔎 **Inspect by process name** - Find all processes matching a name and their ports
51
58
  - 🔪 **Kill processes** - Terminate processes using specific ports
52
- - 📋 **List all ports** - View all listening ports and their processes
59
+ - 💥 **Kill port range** - Terminate processes on a range of ports
60
+ - 🔫 **Kill multiple ports** - Kill processes on multiple ports at once
53
61
  - 🎯 **Kill by process name** - Kill all processes matching a name (e.g., "node", "python")
54
- - 🔥 **Kill multiple ports** - Kill processes on multiple ports at once
62
+ - 📋 **List all ports** - View all listening ports and their processes
55
63
  - 🎨 **Colorized output** - Easy-to-read colored terminal output
56
64
  - ✅ **Confirmation prompts** - Safety confirmation before killing processes
57
65
  - 🌍 **Cross-platform** - Works on Windows, Linux, and macOS
@@ -62,13 +70,17 @@ A simple, powerful command-line tool to inspect and kill processes using specifi
62
70
  ### Quick Install (Once Published to PyPI)
63
71
 
64
72
  ```bash
73
+ # Recommended: Install to user directory
74
+ pip install --user kport
75
+
76
+ # Or install system-wide (requires admin/sudo)
65
77
  pip install kport
66
78
  ```
67
79
 
68
80
  ### Install from GitHub
69
81
 
70
82
  ```bash
71
- pip install git+https://github.com/farman20ali/port-killer.git
83
+ pip install --user git+https://github.com/farman20ali/port-killer.git
72
84
  ```
73
85
 
74
86
  ### Install from Source
@@ -78,7 +90,10 @@ pip install git+https://github.com/farman20ali/port-killer.git
78
90
  git clone https://github.com/farman20ali/port-killer.git
79
91
  cd port-killer
80
92
 
81
- # Install
93
+ # Install to user directory (recommended)
94
+ pip install --user .
95
+
96
+ # Or install system-wide (requires admin/sudo)
82
97
  pip install .
83
98
  ```
84
99
 
@@ -86,7 +101,7 @@ pip install .
86
101
 
87
102
  ```bash
88
103
  # Install in editable mode
89
- pip install -e .
104
+ pip install --user -e .
90
105
  ```
91
106
 
92
107
  After installation, `kport` will be available globally in your terminal.
@@ -98,6 +113,8 @@ After installation, `kport` will be available globally in your terminal.
98
113
  python kport.py -h
99
114
  ```
100
115
 
116
+ > 💡 **Tip:** If `kport` command doesn't work after installation, see [TROUBLESHOOTING.md](TROUBLESHOOTING.md)
117
+ >
101
118
  > 📖 For detailed installation instructions, see [INSTALL.md](INSTALL.md)
102
119
  >
103
120
  > 🚀 For publishing instructions, see [PUBLISH.md](PUBLISH.md)
@@ -150,6 +167,48 @@ PID Process Port State
150
167
  ✓ Total connections: 3
151
168
  ```
152
169
 
170
+ ### Inspect multiple ports
171
+
172
+ Check multiple ports at once:
173
+
174
+ ```bash
175
+ kport -im 3000 3001 8080 8081
176
+ ```
177
+
178
+ Example output:
179
+ ```
180
+ 🔍 Inspecting 4 port(s)...
181
+
182
+ Port PID Process
183
+ ────────────────────────────────────────────────────────────
184
+ 3000 12345 node.exe
185
+ 3001 12346 node.exe
186
+ 8080 12347 python.exe
187
+
188
+ ✓ Found processes on 3/4 port(s)
189
+ ```
190
+
191
+ ### Inspect port range
192
+
193
+ Scan a range of ports:
194
+
195
+ ```bash
196
+ kport -ir 3000-3010
197
+ ```
198
+
199
+ Example output:
200
+ ```
201
+ 🔍 Inspecting port range 3000-3010 (11 ports)...
202
+
203
+ Port PID Process
204
+ ────────────────────────────────────────────────────────────
205
+ 3000 12345 node.exe
206
+ 3001 12346 node.exe
207
+ 3005 12347 python.exe
208
+
209
+ ✓ Found processes on 3/11 port(s) in range
210
+ ```
211
+
153
212
  ### Kill a process on a port
154
213
 
155
214
  Terminate the process using a specific port:
@@ -249,6 +308,34 @@ Are you sure you want to kill 3 process(es)? (y/N): y
249
308
  Ports freed: 3000, 3001, 3002
250
309
  ```
251
310
 
311
+ ### Kill port range
312
+
313
+ Kill all processes on a range of ports:
314
+
315
+ ```bash
316
+ kport -kr 3000-3010
317
+ ```
318
+
319
+ Example output:
320
+ ```
321
+ 🔪 Killing processes on port range 3000-3010 (11 ports)...
322
+
323
+ Found processes on 3 port(s) in range:
324
+ ──────────────────────────────────────────────────
325
+ Port 3000: PID 12345 (node.exe)
326
+ Port 3001: PID 12346 (node.exe)
327
+ Port 3005: PID 12347 (python.exe)
328
+
329
+ Are you sure you want to kill 3 process(es)? (y/N): y
330
+
331
+ ✓ Killed process on port 3000 (PID 12345)
332
+ ✓ Killed process on port 3001 (PID 12346)
333
+ ✓ Killed process on port 3005 (PID 12347)
334
+
335
+ ✓ Successfully killed 3/3 process(es)
336
+ Ports freed: 3000, 3001, 3005
337
+ ```
338
+
252
339
  ### Show help
253
340
 
254
341
  ```bash
@@ -266,10 +353,13 @@ kport -v
266
353
  | Option | Long Form | Description |
267
354
  |--------|-----------|-------------|
268
355
  | `-i PORT` | `--inspect PORT` | Inspect which process is using the specified port |
356
+ | `-im PORT [PORT ...]` | `--inspect-multiple PORT [PORT ...]` | Inspect multiple ports at once |
357
+ | `-ir RANGE` | `--inspect-range RANGE` | Inspect port range (e.g., 3000-3010) |
269
358
  | `-ip NAME` | `--inspect-process NAME` | Inspect all processes matching the given name and their ports |
270
359
  | `-k PORT` | `--kill PORT` | Kill the process using the specified port |
271
360
  | `-kp NAME` | `--kill-process NAME` | Kill all processes matching the given name |
272
361
  | `-ka PORT [PORT ...]` | `--kill-all PORT [PORT ...]` | Kill processes on multiple ports at once |
362
+ | `-kr RANGE` | `--kill-range RANGE` | Kill processes on port range (e.g., 3000-3010) |
273
363
  | `-l` | `--list` | List all listening ports and their processes |
274
364
  | `-v` | `--version` | Show version information |
275
365
  | `-h` | `--help` | Show help message |
@@ -1,15 +1,23 @@
1
1
  # 🔪 kport - Cross-Platform Port Inspector and Killer
2
2
 
3
+ [![Version](https://img.shields.io/badge/version-1.0.0-blue.svg)](https://github.com/farman20ali/port-killer)
4
+ [![Python](https://img.shields.io/badge/python-3.6+-blue.svg)](https://www.python.org/downloads/)
5
+ [![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
6
+ [![Platform](https://img.shields.io/badge/platform-Windows%20%7C%20Linux%20%7C%20macOS-lightgrey.svg)](https://github.com/farman20ali/port-killer)
7
+
3
8
  A simple, powerful command-line tool to inspect and kill processes using specific ports on Windows, Linux, and macOS.
4
9
 
5
10
  ## ✨ Features
6
11
 
7
12
  - 🔍 **Inspect ports** - Find which process is using a specific port
13
+ - 🔎 **Inspect multiple ports** - Check multiple ports at once
14
+ - 🔍 **Inspect port range** - Scan a range of ports (e.g., 3000-3010)
8
15
  - 🔎 **Inspect by process name** - Find all processes matching a name and their ports
9
16
  - 🔪 **Kill processes** - Terminate processes using specific ports
10
- - 📋 **List all ports** - View all listening ports and their processes
17
+ - 💥 **Kill port range** - Terminate processes on a range of ports
18
+ - 🔫 **Kill multiple ports** - Kill processes on multiple ports at once
11
19
  - 🎯 **Kill by process name** - Kill all processes matching a name (e.g., "node", "python")
12
- - 🔥 **Kill multiple ports** - Kill processes on multiple ports at once
20
+ - 📋 **List all ports** - View all listening ports and their processes
13
21
  - 🎨 **Colorized output** - Easy-to-read colored terminal output
14
22
  - ✅ **Confirmation prompts** - Safety confirmation before killing processes
15
23
  - 🌍 **Cross-platform** - Works on Windows, Linux, and macOS
@@ -20,13 +28,17 @@ A simple, powerful command-line tool to inspect and kill processes using specifi
20
28
  ### Quick Install (Once Published to PyPI)
21
29
 
22
30
  ```bash
31
+ # Recommended: Install to user directory
32
+ pip install --user kport
33
+
34
+ # Or install system-wide (requires admin/sudo)
23
35
  pip install kport
24
36
  ```
25
37
 
26
38
  ### Install from GitHub
27
39
 
28
40
  ```bash
29
- pip install git+https://github.com/farman20ali/port-killer.git
41
+ pip install --user git+https://github.com/farman20ali/port-killer.git
30
42
  ```
31
43
 
32
44
  ### Install from Source
@@ -36,7 +48,10 @@ pip install git+https://github.com/farman20ali/port-killer.git
36
48
  git clone https://github.com/farman20ali/port-killer.git
37
49
  cd port-killer
38
50
 
39
- # Install
51
+ # Install to user directory (recommended)
52
+ pip install --user .
53
+
54
+ # Or install system-wide (requires admin/sudo)
40
55
  pip install .
41
56
  ```
42
57
 
@@ -44,7 +59,7 @@ pip install .
44
59
 
45
60
  ```bash
46
61
  # Install in editable mode
47
- pip install -e .
62
+ pip install --user -e .
48
63
  ```
49
64
 
50
65
  After installation, `kport` will be available globally in your terminal.
@@ -56,6 +71,8 @@ After installation, `kport` will be available globally in your terminal.
56
71
  python kport.py -h
57
72
  ```
58
73
 
74
+ > 💡 **Tip:** If `kport` command doesn't work after installation, see [TROUBLESHOOTING.md](TROUBLESHOOTING.md)
75
+ >
59
76
  > 📖 For detailed installation instructions, see [INSTALL.md](INSTALL.md)
60
77
  >
61
78
  > 🚀 For publishing instructions, see [PUBLISH.md](PUBLISH.md)
@@ -108,6 +125,48 @@ PID Process Port State
108
125
  ✓ Total connections: 3
109
126
  ```
110
127
 
128
+ ### Inspect multiple ports
129
+
130
+ Check multiple ports at once:
131
+
132
+ ```bash
133
+ kport -im 3000 3001 8080 8081
134
+ ```
135
+
136
+ Example output:
137
+ ```
138
+ 🔍 Inspecting 4 port(s)...
139
+
140
+ Port PID Process
141
+ ────────────────────────────────────────────────────────────
142
+ 3000 12345 node.exe
143
+ 3001 12346 node.exe
144
+ 8080 12347 python.exe
145
+
146
+ ✓ Found processes on 3/4 port(s)
147
+ ```
148
+
149
+ ### Inspect port range
150
+
151
+ Scan a range of ports:
152
+
153
+ ```bash
154
+ kport -ir 3000-3010
155
+ ```
156
+
157
+ Example output:
158
+ ```
159
+ 🔍 Inspecting port range 3000-3010 (11 ports)...
160
+
161
+ Port PID Process
162
+ ────────────────────────────────────────────────────────────
163
+ 3000 12345 node.exe
164
+ 3001 12346 node.exe
165
+ 3005 12347 python.exe
166
+
167
+ ✓ Found processes on 3/11 port(s) in range
168
+ ```
169
+
111
170
  ### Kill a process on a port
112
171
 
113
172
  Terminate the process using a specific port:
@@ -207,6 +266,34 @@ Are you sure you want to kill 3 process(es)? (y/N): y
207
266
  Ports freed: 3000, 3001, 3002
208
267
  ```
209
268
 
269
+ ### Kill port range
270
+
271
+ Kill all processes on a range of ports:
272
+
273
+ ```bash
274
+ kport -kr 3000-3010
275
+ ```
276
+
277
+ Example output:
278
+ ```
279
+ 🔪 Killing processes on port range 3000-3010 (11 ports)...
280
+
281
+ Found processes on 3 port(s) in range:
282
+ ──────────────────────────────────────────────────
283
+ Port 3000: PID 12345 (node.exe)
284
+ Port 3001: PID 12346 (node.exe)
285
+ Port 3005: PID 12347 (python.exe)
286
+
287
+ Are you sure you want to kill 3 process(es)? (y/N): y
288
+
289
+ ✓ Killed process on port 3000 (PID 12345)
290
+ ✓ Killed process on port 3001 (PID 12346)
291
+ ✓ Killed process on port 3005 (PID 12347)
292
+
293
+ ✓ Successfully killed 3/3 process(es)
294
+ Ports freed: 3000, 3001, 3005
295
+ ```
296
+
210
297
  ### Show help
211
298
 
212
299
  ```bash
@@ -224,10 +311,13 @@ kport -v
224
311
  | Option | Long Form | Description |
225
312
  |--------|-----------|-------------|
226
313
  | `-i PORT` | `--inspect PORT` | Inspect which process is using the specified port |
314
+ | `-im PORT [PORT ...]` | `--inspect-multiple PORT [PORT ...]` | Inspect multiple ports at once |
315
+ | `-ir RANGE` | `--inspect-range RANGE` | Inspect port range (e.g., 3000-3010) |
227
316
  | `-ip NAME` | `--inspect-process NAME` | Inspect all processes matching the given name and their ports |
228
317
  | `-k PORT` | `--kill PORT` | Kill the process using the specified port |
229
318
  | `-kp NAME` | `--kill-process NAME` | Kill all processes matching the given name |
230
319
  | `-ka PORT [PORT ...]` | `--kill-all PORT [PORT ...]` | Kill processes on multiple ports at once |
320
+ | `-kr RANGE` | `--kill-range RANGE` | Kill processes on port range (e.g., 3000-3010) |
231
321
  | `-l` | `--list` | List all listening ports and their processes |
232
322
  | `-v` | `--version` | Show version information |
233
323
  | `-h` | `--help` | Show help message |
@@ -1,10 +1,10 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: kport
3
- Version: 2.0.0
3
+ Version: 2.1.0
4
4
  Summary: A cross-platform command-line tool to inspect and kill processes using specific ports
5
5
  Home-page: https://github.com/farman20ali/port-killer
6
- Author: Farman Ali (Alien)
7
- Author-email: farman20ali@example.com
6
+ Author: Farman Ali
7
+ Author-email: farman20ali@gmail.com
8
8
  Project-URL: Bug Reports, https://github.com/farman20ali/port-killer/issues
9
9
  Project-URL: Source, https://github.com/farman20ali/port-killer
10
10
  Keywords: port,kill,process,network,cross-platform,cli
@@ -42,16 +42,24 @@ Dynamic: summary
42
42
 
43
43
  # 🔪 kport - Cross-Platform Port Inspector and Killer
44
44
 
45
+ [![Version](https://img.shields.io/badge/version-1.0.0-blue.svg)](https://github.com/farman20ali/port-killer)
46
+ [![Python](https://img.shields.io/badge/python-3.6+-blue.svg)](https://www.python.org/downloads/)
47
+ [![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
48
+ [![Platform](https://img.shields.io/badge/platform-Windows%20%7C%20Linux%20%7C%20macOS-lightgrey.svg)](https://github.com/farman20ali/port-killer)
49
+
45
50
  A simple, powerful command-line tool to inspect and kill processes using specific ports on Windows, Linux, and macOS.
46
51
 
47
52
  ## ✨ Features
48
53
 
49
54
  - 🔍 **Inspect ports** - Find which process is using a specific port
55
+ - 🔎 **Inspect multiple ports** - Check multiple ports at once
56
+ - 🔍 **Inspect port range** - Scan a range of ports (e.g., 3000-3010)
50
57
  - 🔎 **Inspect by process name** - Find all processes matching a name and their ports
51
58
  - 🔪 **Kill processes** - Terminate processes using specific ports
52
- - 📋 **List all ports** - View all listening ports and their processes
59
+ - 💥 **Kill port range** - Terminate processes on a range of ports
60
+ - 🔫 **Kill multiple ports** - Kill processes on multiple ports at once
53
61
  - 🎯 **Kill by process name** - Kill all processes matching a name (e.g., "node", "python")
54
- - 🔥 **Kill multiple ports** - Kill processes on multiple ports at once
62
+ - 📋 **List all ports** - View all listening ports and their processes
55
63
  - 🎨 **Colorized output** - Easy-to-read colored terminal output
56
64
  - ✅ **Confirmation prompts** - Safety confirmation before killing processes
57
65
  - 🌍 **Cross-platform** - Works on Windows, Linux, and macOS
@@ -62,13 +70,17 @@ A simple, powerful command-line tool to inspect and kill processes using specifi
62
70
  ### Quick Install (Once Published to PyPI)
63
71
 
64
72
  ```bash
73
+ # Recommended: Install to user directory
74
+ pip install --user kport
75
+
76
+ # Or install system-wide (requires admin/sudo)
65
77
  pip install kport
66
78
  ```
67
79
 
68
80
  ### Install from GitHub
69
81
 
70
82
  ```bash
71
- pip install git+https://github.com/farman20ali/port-killer.git
83
+ pip install --user git+https://github.com/farman20ali/port-killer.git
72
84
  ```
73
85
 
74
86
  ### Install from Source
@@ -78,7 +90,10 @@ pip install git+https://github.com/farman20ali/port-killer.git
78
90
  git clone https://github.com/farman20ali/port-killer.git
79
91
  cd port-killer
80
92
 
81
- # Install
93
+ # Install to user directory (recommended)
94
+ pip install --user .
95
+
96
+ # Or install system-wide (requires admin/sudo)
82
97
  pip install .
83
98
  ```
84
99
 
@@ -86,7 +101,7 @@ pip install .
86
101
 
87
102
  ```bash
88
103
  # Install in editable mode
89
- pip install -e .
104
+ pip install --user -e .
90
105
  ```
91
106
 
92
107
  After installation, `kport` will be available globally in your terminal.
@@ -98,6 +113,8 @@ After installation, `kport` will be available globally in your terminal.
98
113
  python kport.py -h
99
114
  ```
100
115
 
116
+ > 💡 **Tip:** If `kport` command doesn't work after installation, see [TROUBLESHOOTING.md](TROUBLESHOOTING.md)
117
+ >
101
118
  > 📖 For detailed installation instructions, see [INSTALL.md](INSTALL.md)
102
119
  >
103
120
  > 🚀 For publishing instructions, see [PUBLISH.md](PUBLISH.md)
@@ -150,6 +167,48 @@ PID Process Port State
150
167
  ✓ Total connections: 3
151
168
  ```
152
169
 
170
+ ### Inspect multiple ports
171
+
172
+ Check multiple ports at once:
173
+
174
+ ```bash
175
+ kport -im 3000 3001 8080 8081
176
+ ```
177
+
178
+ Example output:
179
+ ```
180
+ 🔍 Inspecting 4 port(s)...
181
+
182
+ Port PID Process
183
+ ────────────────────────────────────────────────────────────
184
+ 3000 12345 node.exe
185
+ 3001 12346 node.exe
186
+ 8080 12347 python.exe
187
+
188
+ ✓ Found processes on 3/4 port(s)
189
+ ```
190
+
191
+ ### Inspect port range
192
+
193
+ Scan a range of ports:
194
+
195
+ ```bash
196
+ kport -ir 3000-3010
197
+ ```
198
+
199
+ Example output:
200
+ ```
201
+ 🔍 Inspecting port range 3000-3010 (11 ports)...
202
+
203
+ Port PID Process
204
+ ────────────────────────────────────────────────────────────
205
+ 3000 12345 node.exe
206
+ 3001 12346 node.exe
207
+ 3005 12347 python.exe
208
+
209
+ ✓ Found processes on 3/11 port(s) in range
210
+ ```
211
+
153
212
  ### Kill a process on a port
154
213
 
155
214
  Terminate the process using a specific port:
@@ -249,6 +308,34 @@ Are you sure you want to kill 3 process(es)? (y/N): y
249
308
  Ports freed: 3000, 3001, 3002
250
309
  ```
251
310
 
311
+ ### Kill port range
312
+
313
+ Kill all processes on a range of ports:
314
+
315
+ ```bash
316
+ kport -kr 3000-3010
317
+ ```
318
+
319
+ Example output:
320
+ ```
321
+ 🔪 Killing processes on port range 3000-3010 (11 ports)...
322
+
323
+ Found processes on 3 port(s) in range:
324
+ ──────────────────────────────────────────────────
325
+ Port 3000: PID 12345 (node.exe)
326
+ Port 3001: PID 12346 (node.exe)
327
+ Port 3005: PID 12347 (python.exe)
328
+
329
+ Are you sure you want to kill 3 process(es)? (y/N): y
330
+
331
+ ✓ Killed process on port 3000 (PID 12345)
332
+ ✓ Killed process on port 3001 (PID 12346)
333
+ ✓ Killed process on port 3005 (PID 12347)
334
+
335
+ ✓ Successfully killed 3/3 process(es)
336
+ Ports freed: 3000, 3001, 3005
337
+ ```
338
+
252
339
  ### Show help
253
340
 
254
341
  ```bash
@@ -266,10 +353,13 @@ kport -v
266
353
  | Option | Long Form | Description |
267
354
  |--------|-----------|-------------|
268
355
  | `-i PORT` | `--inspect PORT` | Inspect which process is using the specified port |
356
+ | `-im PORT [PORT ...]` | `--inspect-multiple PORT [PORT ...]` | Inspect multiple ports at once |
357
+ | `-ir RANGE` | `--inspect-range RANGE` | Inspect port range (e.g., 3000-3010) |
269
358
  | `-ip NAME` | `--inspect-process NAME` | Inspect all processes matching the given name and their ports |
270
359
  | `-k PORT` | `--kill PORT` | Kill the process using the specified port |
271
360
  | `-kp NAME` | `--kill-process NAME` | Kill all processes matching the given name |
272
361
  | `-ka PORT [PORT ...]` | `--kill-all PORT [PORT ...]` | Kill processes on multiple ports at once |
362
+ | `-kr RANGE` | `--kill-range RANGE` | Kill processes on port range (e.g., 3000-3010) |
273
363
  | `-l` | `--list` | List all listening ports and their processes |
274
364
  | `-v` | `--version` | Show version information |
275
365
  | `-h` | `--help` | Show help message |
@@ -50,6 +50,35 @@ def validate_port(port):
50
50
  sys.exit(1)
51
51
 
52
52
 
53
+ def parse_port_range(port_range):
54
+ """Parse port range string (e.g., '3000-3010') into list of ports"""
55
+ try:
56
+ if '-' in port_range:
57
+ start, end = port_range.split('-')
58
+ start_port = int(start.strip())
59
+ end_port = int(end.strip())
60
+
61
+ if start_port > end_port:
62
+ print(colorize(f"Error: Invalid range {port_range}. Start port must be less than end port.", Colors.RED))
63
+ sys.exit(1)
64
+
65
+ if end_port - start_port > 1000:
66
+ print(colorize(f"Error: Range too large ({end_port - start_port} ports). Maximum 1000 ports allowed.", Colors.RED))
67
+ sys.exit(1)
68
+
69
+ ports = list(range(start_port, end_port + 1))
70
+ for port in ports:
71
+ validate_port(port)
72
+ return ports
73
+ else:
74
+ port = int(port_range)
75
+ validate_port(port)
76
+ return [port]
77
+ except ValueError:
78
+ print(colorize(f"Error: Invalid port or range format: {port_range}", Colors.RED))
79
+ sys.exit(1)
80
+
81
+
53
82
  def find_pid(port):
54
83
  """Find process ID using given port"""
55
84
  system = platform.system()
@@ -230,16 +259,23 @@ def main():
230
259
  parser = argparse.ArgumentParser(
231
260
  description="🔪 kport - Cross-platform port inspector and killer",
232
261
  epilog="Examples:\n"
233
- " kport -i 8080 Inspect port 8080\n"
234
- " kport -ip node Inspect all processes matching 'node'\n"
235
- " kport -k 8080 Kill process using port 8080\n"
236
- " kport -l List all listening ports\n"
237
- " kport -kp node Kill all processes matching 'node'\n"
238
- " kport -ka 3000 3001 3002 Kill processes on multiple ports\n",
262
+ " kport -i 8080 Inspect port 8080\n"
263
+ " kport -im 3000 3001 3002 Inspect multiple ports\n"
264
+ " kport -ir 3000-3010 Inspect port range\n"
265
+ " kport -ip node Inspect all processes matching 'node'\n"
266
+ " kport -k 8080 Kill process using port 8080\n"
267
+ " kport -ka 3000 3001 3002 Kill processes on multiple ports\n"
268
+ " kport -kr 3000-3010 Kill processes on port range\n"
269
+ " kport -kp node Kill all processes matching 'node'\n"
270
+ " kport -l List all listening ports\n",
239
271
  formatter_class=argparse.RawDescriptionHelpFormatter
240
272
  )
241
273
  parser.add_argument("-i", "--inspect", type=int, metavar="PORT",
242
274
  help="Inspect which process is using the specified port")
275
+ parser.add_argument("-im", "--inspect-multiple", type=int, nargs="+", metavar="PORT",
276
+ help="Inspect multiple ports")
277
+ parser.add_argument("-ir", "--inspect-range", type=str, metavar="RANGE",
278
+ help="Inspect port range (e.g., 3000-3010)")
243
279
  parser.add_argument("-ip", "--inspect-process", type=str, metavar="NAME",
244
280
  help="Inspect all processes matching the given name")
245
281
  parser.add_argument("-k", "--kill", type=int, metavar="PORT",
@@ -248,20 +284,67 @@ def main():
248
284
  help="Kill all processes matching the given name")
249
285
  parser.add_argument("-ka", "--kill-all", type=int, nargs="+", metavar="PORT",
250
286
  help="Kill processes on multiple ports")
287
+ parser.add_argument("-kr", "--kill-range", type=str, metavar="RANGE",
288
+ help="Kill processes on port range (e.g., 3000-3010)")
251
289
  parser.add_argument("-l", "--list", action="store_true",
252
290
  help="List all listening ports and their processes")
253
- parser.add_argument("-v", "--version", action="version", version="kport 2.0.0")
291
+ parser.add_argument("-v", "--version", action="version", version="kport 2.1.0")
254
292
 
255
293
  args = parser.parse_args()
256
294
 
257
295
  # If no arguments provided, show help
258
- if not (args.inspect or args.inspect_process or args.kill or args.list or args.kill_process or args.kill_all):
296
+ if not (args.inspect or args.inspect_multiple or args.inspect_range or args.inspect_process or
297
+ args.kill or args.list or args.kill_process or args.kill_all or args.kill_range):
259
298
  parser.print_help()
260
299
  sys.exit(0)
261
300
 
262
301
  if args.list:
263
302
  list_all_ports()
264
303
 
304
+ if args.inspect_multiple:
305
+ print(colorize(f"\n🔍 Inspecting {len(args.inspect_multiple)} port(s)...\n", Colors.CYAN + Colors.BOLD))
306
+
307
+ results = []
308
+ for port in args.inspect_multiple:
309
+ validate_port(port)
310
+ pid, info = find_pid(port)
311
+ if pid:
312
+ proc_name = get_process_name(pid)
313
+ results.append((port, pid, proc_name))
314
+
315
+ if not results:
316
+ print(colorize(f"❌ No processes found on any of the specified ports", Colors.RED))
317
+ else:
318
+ print(colorize(f"{'Port':<10} {'PID':<10} {'Process':<30}", Colors.BOLD))
319
+ print("─" * 60)
320
+
321
+ for port, pid, proc_name in results:
322
+ print(f"{colorize(str(port), Colors.CYAN):<19} {pid:<10} {proc_name:<30}")
323
+
324
+ print(colorize(f"\n✓ Found processes on {len(results)}/{len(args.inspect_multiple)} port(s)", Colors.GREEN))
325
+
326
+ if args.inspect_range:
327
+ ports = parse_port_range(args.inspect_range)
328
+ print(colorize(f"\n🔍 Inspecting port range {args.inspect_range} ({len(ports)} ports)...\n", Colors.CYAN + Colors.BOLD))
329
+
330
+ results = []
331
+ for port in ports:
332
+ pid, info = find_pid(port)
333
+ if pid:
334
+ proc_name = get_process_name(pid)
335
+ results.append((port, pid, proc_name))
336
+
337
+ if not results:
338
+ print(colorize(f"❌ No processes found in port range {args.inspect_range}", Colors.RED))
339
+ else:
340
+ print(colorize(f"{'Port':<10} {'PID':<10} {'Process':<30}", Colors.BOLD))
341
+ print("─" * 60)
342
+
343
+ for port, pid, proc_name in results:
344
+ print(f"{colorize(str(port), Colors.CYAN):<19} {pid:<10} {proc_name:<30}")
345
+
346
+ print(colorize(f"\n✓ Found processes on {len(results)}/{len(ports)} port(s) in range", Colors.GREEN))
347
+
265
348
  if args.inspect_process:
266
349
  print(colorize(f"\n🔍 Inspecting processes matching '{args.inspect_process}'...\n", Colors.CYAN + Colors.BOLD))
267
350
 
@@ -381,6 +464,50 @@ def main():
381
464
  print(colorize(f"\n✓ Successfully killed {killed_count}/{len(port_pid_map)} process(es)", Colors.GREEN + Colors.BOLD))
382
465
  print(colorize(f"Ports freed: {', '.join(map(str, port_pid_map.keys()))}", Colors.GREEN))
383
466
 
467
+ if args.kill_range:
468
+ ports = parse_port_range(args.kill_range)
469
+ print(colorize(f"\n🔪 Killing processes on port range {args.kill_range} ({len(ports)} ports)...\n", Colors.CYAN + Colors.BOLD))
470
+
471
+ # Find all PIDs in range
472
+ port_pid_map = {}
473
+ for port in ports:
474
+ pid, info = find_pid(port)
475
+ if pid:
476
+ port_pid_map[port] = (pid, info)
477
+
478
+ if not port_pid_map:
479
+ print(colorize(f"❌ No processes found in port range {args.kill_range}", Colors.RED))
480
+ else:
481
+ print(colorize(f"Found processes on {len(port_pid_map)} port(s) in range:", Colors.YELLOW))
482
+ print("─" * 50)
483
+
484
+ for port, (pid, info) in port_pid_map.items():
485
+ proc_name = get_process_name(pid)
486
+ print(colorize(f" Port {port}: PID {pid} ({proc_name})", Colors.WHITE))
487
+
488
+ # Ask for confirmation
489
+ try:
490
+ confirm = input(colorize(f"\nAre you sure you want to kill {len(port_pid_map)} process(es)? (y/N): ", Colors.MAGENTA))
491
+ if confirm.lower() not in ['y', 'yes']:
492
+ print(colorize("Operation cancelled.", Colors.YELLOW))
493
+ sys.exit(0)
494
+ except KeyboardInterrupt:
495
+ print(colorize("\n\nOperation cancelled.", Colors.YELLOW))
496
+ sys.exit(0)
497
+
498
+ # Kill all processes
499
+ killed_count = 0
500
+ for port, (pid, info) in port_pid_map.items():
501
+ result = kill_pid(pid, silent=True)
502
+ if result or "SUCCESS" in str(result) or "killed" in str(result).lower():
503
+ killed_count += 1
504
+ print(colorize(f"✓ Killed process on port {port} (PID {pid})", Colors.GREEN))
505
+ else:
506
+ print(colorize(f"✗ Failed to kill process on port {port} (PID {pid})", Colors.RED))
507
+
508
+ print(colorize(f"\n✓ Successfully killed {killed_count}/{len(port_pid_map)} process(es)", Colors.GREEN + Colors.BOLD))
509
+ print(colorize(f"Ports freed: {', '.join(map(str, port_pid_map.keys()))}", Colors.GREEN))
510
+
384
511
  if args.inspect:
385
512
  validate_port(args.inspect)
386
513
  print(colorize(f"\n🔍 Inspecting port {args.inspect}...\n", Colors.CYAN + Colors.BOLD))
@@ -8,9 +8,9 @@ with open("README.md", "r", encoding="utf-8") as fh:
8
8
 
9
9
  setup(
10
10
  name="kport",
11
- version="2.0.0",
12
- author="Farman Ali (Alien)",
13
- author_email="farman20ali@example.com",
11
+ version="2.1.0",
12
+ author="Farman Ali",
13
+ author_email="farman20ali@gmail.com",
14
14
  description="A cross-platform command-line tool to inspect and kill processes using specific ports",
15
15
  long_description=long_description,
16
16
  long_description_content_type="text/markdown",
File without changes
File without changes
File without changes