port-patrol 1.0.0 → 1.0.1

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.
Files changed (3) hide show
  1. package/README.md +2 -0
  2. package/dist/cli.js +47 -3
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -8,6 +8,8 @@ A terminal UI to inspect listening ports and terminate the owning process.
8
8
 
9
9
  Built with [Ink](https://github.com/vadimdemedes/ink) + [React](https://react.dev).
10
10
 
11
+ ![Port Patrol - Main view](./assets/port-patrol.png)
12
+
11
13
  ## Features
12
14
 
13
15
  - **List all listening ports** with process info
package/dist/cli.js CHANGED
@@ -1,12 +1,56 @@
1
1
  #!/usr/bin/env node
2
+ import { readFileSync } from "fs";
3
+ import { fileURLToPath } from "url";
4
+ import { dirname, join } from "path";
2
5
  import { run } from "./index.js";
3
- // Parse CLI args for quick port lookup
6
+ const __filename = fileURLToPath(import.meta.url);
7
+ const __dirname = dirname(__filename);
8
+ function getVersion() {
9
+ try {
10
+ const pkgPath = join(__dirname, "..", "package.json");
11
+ const pkg = JSON.parse(readFileSync(pkgPath, "utf-8"));
12
+ return pkg.version;
13
+ }
14
+ catch {
15
+ return "unknown";
16
+ }
17
+ }
18
+ function showHelp() {
19
+ console.log(`
20
+ Port Patrol - Inspect listening ports and kill the owning process
21
+
22
+ Usage: pp [port] [options]
23
+
24
+ Options:
25
+ -v, --version Show version number
26
+ -h, --help Show this help message
27
+
28
+ Shortcuts:
29
+ / or f Search/filter
30
+ Enter Kill selected process
31
+ K Force kill (SIGKILL)
32
+ r Refresh list
33
+ s Toggle sort field
34
+ o Toggle sort order
35
+ ? Show help
36
+ q Quit
37
+ `);
38
+ }
4
39
  const args = process.argv.slice(2);
40
+ if (args.includes("-v") || args.includes("--version")) {
41
+ console.log(getVersion());
42
+ process.exit(0);
43
+ }
44
+ if (args.includes("-h") || args.includes("--help")) {
45
+ showHelp();
46
+ process.exit(0);
47
+ }
5
48
  let initialPort;
6
- if (args.length > 0) {
7
- const portArg = parseInt(args[0], 10);
49
+ for (const arg of args) {
50
+ const portArg = parseInt(arg, 10);
8
51
  if (!isNaN(portArg)) {
9
52
  initialPort = portArg;
53
+ break;
10
54
  }
11
55
  }
12
56
  run(initialPort);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "port-patrol",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "TUI to inspect listening ports and terminate the owning process.",
5
5
  "type": "module",
6
6
  "license": "MIT",