Repository navigation
Add --json to graphcode projects and graphcode workspaces - #938
Merged
Merged
Conversation
Tools that enumerate every workspace and the projects in each had to scrape two-space-separated text, and `projects` printed "no projects yet" instead of an empty list. `--json` prints each list as a JSON array: projects carry name, path and lastOpenedAt; workspaces carry name, path and current. `projects --help`/`-h` now print help like every other verb, instead of "unknown option" or a silent listing. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 40117320-498b-4a94-9420-19ba4ea5882b Signed-off-by: Zeke Arany-Lucas <93434462+ZekeAranyLucas@users.noreply.github.com>
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
Adds
--jsontographcode projectsandgraphcode workspaces, so a tool can enumerate every workspace and the projects in each without scraping text. Follow-up to #925.Why
An external tool needs to list both. The text output is meant for people: two-space-separated columns, a
*marker, andno projects yetinstead of an empty list. The two lists get the flag together so they stay consistent.Before / after (real runs on macOS)
Before (the installed Homebrew
graphcode, which predates #925, soworkspacesitself is unknown; on main after #925workspaces --jsonfails withunknown option: --json, which the earlier PR's own run showed):After (this branch's
graphcode, built withswift build --product graphcode, talking to the running daemon):Text output without
--jsonis unchanged.How to observe after merge
Each workspace's
projectsgoes through that workspace's own daemon. A workspace whose daemon isn't running fails as it already did (exit 69, "graphcoded isn't running").Risks / rollback
Additive. The JSON shape is new and has one consumer. Keys are sorted, dates are ISO 8601 (same as
mail --json), and slashes are not escaped. One small behavior change:graphcode projects --help/-hnow print help, as every other verb does. Before,--helpwas rejected as an unknown option and-hwas silently ignored. Rollback is a plain revert.Changes
GraphcodeCommand:.listProjects(json:)and.listWorkspaces(json:); both verbs accept--jsonand treat--help/-has help;renderJSONfor each list, through one shared encoder; help text updated.graphcode-cli/main.swift: prints the JSON renderer when--jsonis passed.graphcode/Tests/GraphcodeWorkspacesCommandTests.swiftrenamed toGraphcodeListingCommandTests.swift, now covering both lists: parsing, help, text, JSON shape, empty array.Test plan
make testwas not run. This machine lacks the macOS 15 SDK, the Metal toolchain, and GhosttyKit (make doctor), so the app test bundle can't build here, the same limitation as #925. The test files were compiled and run withswift testfrom a scratch SwiftPM package that depends on this checkout'sGraphcodeKitproduct. The test sources are identical, but the runner is not Xcode'sgraphcodeTestsbundle.RED: swift test (scratch harness, graphcode/Tests/GraphcodeListingCommandTests.swift) -> compile failure: type 'GraphcodeCommand' has no member 'renderJSON' (a missing-API compile error, not a behavioral failure)
GREEN: swift test (same harness, same file) -> 8 tests in 1 suite passed
REGRESSION: swift test (harness plus GraphcodeCommandTests, GraphcodeCommandPromoteTests, MailroomCommandTests, WorkspaceTests) -> 97 tests in 5 suites passed; make check -> exit 0, 312 violations, same count as main
Checklist
git commit -s) per the DCOmake test): not run, see Test plan; the affected suites passed through SwiftPM insteadmake check)