Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ With `--kill`, every port gets a status line (`✓` stopped, `ℹ` left untouche
| :-: | --- | --- |
| 🛑 | `-k`, `--kill` | stop the cause of a busy port after confirmation |
| ✅ | `-y`, `--yes` | skip the confirmation prompt (requires `--kill`) |
| 💥 | `--force` | send SIGKILL immediately instead of SIGTERM (only has an effect together with `--kill`) |
| 💥 | `--force` | send SIGKILL immediately instead of SIGTERM (requires `--kill`) |
| 👀 | `--dry-run` | show what `--kill` would do without doing it |
| 🔎 | `--source <name>` | only show ports held by this source: `docker`, `systemd`, `launchd` or `process` (repeatable, comma-separated) |
| 🤖 | `--json` | print machine-readable JSON (`"version": 1`) |
Expand Down
3 changes: 3 additions & 0 deletions internal/cli/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ func Run(ctx context.Context, d Deps, args []string, flags Flags) int {
if flags.Yes && !flags.Kill {
return fail(d, errors.New("--yes requires --kill"))
}
if flags.Force && !flags.Kill {
return fail(d, errors.New("--force requires --kill"))
}

svc := report.Service{Sockets: d.Sockets, Procs: d.Procs, Detector: d.Detector}
reports, err := svc.Explain(ctx, ports)
Expand Down
13 changes: 13 additions & 0 deletions internal/cli/run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,19 @@ func TestRun_YesWithoutKillExit2(t *testing.T) {
}
}

func TestRun_ForceWithoutKillExit2(t *testing.T) {
d, _, stderr := testDeps(fakeSockets{sockets: []socket.Socket{listener(3000, 42)}})

got := Run(context.Background(), d, []string{"3000"}, Flags{Force: true})

if got != 2 {
t.Errorf("exit = %d, want 2", got)
}
if !strings.Contains(stderr.String(), "--force requires --kill") {
t.Errorf("stderr = %q, want it to contain %q", stderr.String(), "--force requires --kill")
}
}

func TestRun_NoColorWhenNotTTY(t *testing.T) {
d, stdout, _ := testDeps(fakeSockets{sockets: []socket.Socket{listener(3000, 42)}})

Expand Down
Loading