fix(commands): handlers call out:exit() instead of returning to main #47

Closed
opened 2026-05-25 13:48:32 +02:00 by michael · 0 comments
Owner

Problem

Command handlers in core/commands/code.lua and core/commands/article.lua
call out:exit() directly instead of returning nil, err:

local exit_code = reporter.report(results, file_count, suppressions, out)
if exit_code > 0 then out:exit(exit_code) end
return true, nil

Design rule: only main.lua calls exit. All other code returns to the
caller with nil, err. A handler that calls exit bypasses any cleanup,
breaks multi-provider dispatch, and makes the handler untestable.

Fix

Return the exit code as an error signal to the caller instead:

if exit_code > 0 then
  return nil, "[EXIT:" .. exit_code .. "]"
end
return true, nil

Caller (main.lua) interprets the signal and exits. Exact protocol TBD.

Acceptance criteria

  • No out:exit() or os.exit() in command handlers
  • Exit code propagated to main.lua via return value
  • Handlers fully return to caller in all paths
## Problem Command handlers in `core/commands/code.lua` and `core/commands/article.lua` call `out:exit()` directly instead of returning `nil, err`: ```lua local exit_code = reporter.report(results, file_count, suppressions, out) if exit_code > 0 then out:exit(exit_code) end return true, nil ``` Design rule: only `main.lua` calls exit. All other code returns to the caller with `nil, err`. A handler that calls exit bypasses any cleanup, breaks multi-provider dispatch, and makes the handler untestable. ## Fix Return the exit code as an error signal to the caller instead: ```lua if exit_code > 0 then return nil, "[EXIT:" .. exit_code .. "]" end return true, nil ``` Caller (main.lua) interprets the signal and exits. Exact protocol TBD. ## Acceptance criteria - [ ] No `out:exit()` or `os.exit()` in command handlers - [ ] Exit code propagated to main.lua via return value - [ ] Handlers fully return to caller in all paths
michael added this to the Basic Version milestone 2026-05-30 16:05:00 +02:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
DAW/fragjan#47
No description provided.