fix(cli): server-required commands throw instead of silent-exit (#2229) - #2237
Merged
Conversation
…silent exit (#2229) Nine LuCLI commands printed a red "No running Wheels server detected" diagnostic then `return ""` — producing exit 0. MCP clients and shell automation couldn't distinguish "succeeded with no output" from "server down, nothing ran". The issue listed four (routes, reload, test, console); the same-root-cause scan surfaced five more with an identical pattern (migrate, seed, db status, db version, generate admin). All nine fixed together — the issue checklist explicitly covers "any others surfaced by audit". Mirrors the #2211/#2214/#2215 pattern: keep the out() diagnostic, throw a typed `Wheels.*` exception so LuCLI's Picocli ExecutionExceptionHandler surfaces exit 1. - New `$requireRunningServer(hints)` private helper consolidates the guard — returns the detected port on success, throws `Wheels.ServerNotRunning` on failure. - Nine call sites converted: reload(), routes(), console(), generateAdmin, runMigration, runSeed, dbStatus, dbVersion, runTests. - `info()` status probe at line 596 intentionally left alone — it reports server status, doesn't require server. Net -4 LOC across Module.cfc despite adding the helper + docblock, because the guard boilerplate collapses from ~5 lines per site to 1. Regression test `test-server-required-exit-codes.sh` invokes each command with no server and asserts exit != 0 plus the diagnostic. Console is excluded from the live test (its success path reads stdin, making headless exercise awkward); it's covered by type parity with the other throws.
…rzakhani-27b839 # Conflicts: # CHANGELOG.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
return ""— exit 0. MCP clients and shell automation couldn't distinguish "succeeded with no output" from "server down, nothing ran".$requireRunningServer(hints)private helper: returns the port on success, throws typedWheels.ServerNotRunningon failure. LuCLI's PicocliExecutionExceptionHandlermaps the exception to exit 1 — same pattern as the merged wheels new exits 0 when framework-not-found, masks fatal errors to automation #2211/wheels new: remaining silent-exit-0 error paths in scaffoldNewApp #2214/wheels new: explicit WHEELS_FRAMEWORK_PATH should hard-fail when it doesn't exist #2215 fixes forwheels new.routes,reload,test,console); same-root-cause scan surfaced 5 more with identical pattern (migrate,seed,db status,db version,generate admin). All 9 fixed together since the issue checklist explicitly covers "any others surfaced by audit".Closes #2229.
Changes
cli/lucli/Module.cfc$requireRunningServer()helper; converted 9 call sitescli/lucli/tests/test-server-required-exit-codes.shCHANGELOG.md[Unreleased] › FixedentryNet -4 LOC across
Module.cfc— guard collapses from ~5 lines per site to 1.info()status probe at line 596 is intentionally left alone — it reports server status, doesn't require server.Test plan
bash cli/lucli/tests/test-server-required-exit-codes.sh(requires no server on 8080/60000/3000/8500 — the test guards this)wheels routes— expect red diagnostic + exit 1wheels test— expect red diagnostic + two yellow hints + exit 1wheels routes/wheels migrate info/wheels db statuscontinue to succeed (happy-path unchanged)Notes
migrate()hastry { runMigration } catch (MigrationError e)—Wheels.ServerNotRunningis a different type, so it propagates cleanly. The typed exception is load-bearing; acatch (any)anywhere in the chain would silently revert the fix.~/.wheels/modules/wheels/Module.cfcwill shadow worktree changes otherwise (exactly the case wheels doctor: detect stale~/.wheels/modules/wheels/install that shadows source checkout #2223'swheels doctorwas shipped to catch).