Repository navigation
[NYL-1012] Honour --json on the dashboard commands an agent drives - #130
radenkovic wants to merge 1 commit into
Conversation
`nylas dashboard status`, `apps create|use`, `apps apikeys create` and `orgs switch` printed text whatever the output flags said, and the list commands printed a sentence instead of `[]` when empty. An agent or a script could not read the result. - Each now honours --json, --format yaml and --quiet through common.GetOutputWriter, with reports in dashboard/output.go. - A secret is never written in any format: apps create and apikeys create report how it was delivered (method, delivered, file), not its value. Delivery moved into deliverAPIKey/deliverClientSecret so the text and structured forms share it. - A structured run never prompts: it requires --delivery, --secret-delivery, an app ID for `apps use` and --org for `orgs switch`. Progress and partial-region warnings go to stderr. - `status --json` reports logged_in false when signed out, exiting 0 like the text form. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Code review findings7 findings: 3 important, 2 nits, 2 pre-existing. They come from one review pass and were not re-checked, so please confirm each one before you act on it. 🔴 Important1.
2.
3.
🟡 Nit4.
5.
⚪ Pre-existing (more visible after this PR)6.
7.
|
Why
NYL-1012: the upcoming Claude Code / Codex plugin (NYL-1013) drives
nylas dashboardfrom an agent's shell, which needs to read results instead of scraping text. Several commands ignored--json.This PR is the
--jsonpart of NYL-1012. Exit codes, non-blocking device login and the install path follow separately.What changed
dashboard status{"logged_in": false, ...}when signed out (exit 0, like the text)apps createapplication_id,region,environment,client_secretdeliveryapps use{application_id, region}apps apikeys createid,name,application_id,region,deliveryorgs switch{organization_id, organization_name, switched}apps list,apikeys list,orgs list[]method,delivered,file), never its value. The delivery logic moved todeliverAPIKey/deliverClientSecretindashboard/output.go, so text and structured forms share it. The text wording is unchanged.--delivery,--secret-delivery, an app ID forapps useand--orgfororgs switch, because a prompt would write into the stream being parsed and hang an agent's tool call. Progress and partial-region warnings go to stderr.isInteractiveis now a variable so a test can simulate a terminal and prove that--jsonalone stops the prompt.docs/COMMANDS.md.Testing
dashboard/output_test.go. They cover: no secret in JSON, YAML or quiet output; the secret file has 0600 permissions; structured runs refuse instead of prompting; the status report; and OAuthorgs switchreporting the org that was chosen. I checked the prompt test with a mutation: removing the structured check makes it fail.go test ./...,go test -raceon the package,go vet,gofmtandgolangci-lint(0 issues) pass locally.status --json,orgs list --jsonandapps list --jsonagainst a live production session. I didn't create apps or keys against production, so those paths are covered by unit tests only.make vulnfails locally on Go standard-library advisories for the pinnedgo1.26.5(fixed in 1.26.6). They are not related to this diff.Known, not changed here
--delivery activatefails, the CLI prints a warning, exits 0, and the new key is lost. JSON now shows"delivered": false, but the key still can't be recovered. A fallback to file delivery would fix it.orgs list --jsonstill prints"current": "✓". I left it alone so existing scripts don't break.🤖 Generated with Claude Code