Refactor status command to use JSON protocol#191
Open
nsams wants to merge 2 commits into
Open
Conversation
Extracted from PR #177. The status daemon-command previously rendered a cli-table3 table (with ANSI colors via log-update) directly into the socket. Move that rendering to the CLI client: the daemon now emits a newline-delimited JSON array of ScriptStatusEntry objects (or a JSON error object), and the client parses each line and renders the table locally, using log-update for the --interval refresh case. Because connect() no longer auto-pipes socket data to stdout (the status client needs to consume the data itself), pipeToStdout() is extracted as an explicit helper that the start/stop/restart/logs/shutdown commands call.
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.
mainly in preparation for #177, but imho generally a better idea to use a json protocol and render the table client side.
Description
The status command previously rendered tables directly in the daemon process and streamed the formatted output to the client. This approach mixed presentation logic with daemon logic and made it difficult to handle the status command differently from other commands.
This change separates concerns by:
getScriptEntries()functionScriptStatusEntryinterface for type safetyAdditionally, the
connect()function's default data handler is extracted into a newpipeToStdout()function, which is now explicitly called by commands that need it (logs, restart, shutdown, start, stop). This allows the status command to handle data differently without affecting other commands.Benefits:
pipeToStdout()callshttps://claude.ai/code/session_01Atpc7SdHY1FwGiMUyjXAMB