feat(cli): add -f/--format to webcmd profile list - #326
Open
rohan911438 wants to merge 1 commit into
Open
Conversation
Local `profile list` rejected `-f` entirely and only printed prose, while hosted `profile list` already supports `-f json|yaml|csv|md` (src/hosted/runner.ts) — the same command name behaving differently between modes with no indication why (agentrhq#175). Add `-f, --format` (default `table`, prose output unchanged). Other formats render one row per profile through the shared output path. Row shape aligns with hosted's where the concept overlaps (`default`), plus locally-meaningful fields hosted doesn't have (`connected`, `runtimeVersion`) since Cloak profiles are live runtime connections, not persisted Cloud records. Disconnected saved aliases (already shown in the prose output) are included as `connected: false` rows so the structured view doesn't silently drop information the text view shows. The daemon-not-running/stale/no-profiles branches render `[]` for non-table formats rather than swallowing output, mirroring the existing `adapter status` empty-list convention. Scope note: same slice-of-agentrhq#175 approach as the `validate` and `daemon status` PRs. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Contributor
🟠 Maintainer review suggested — low confidenceThe automated review could not reach a fully supported conclusion. Limitations
This review is advisory and does not block merging. |
There was a problem hiding this comment.
Pull request overview
This PR adds structured output formatting to the local webcmd profile list command so it can emit machine-readable results (via the shared renderOutput path) and behave more consistently with hosted mode’s profile list.
Changes:
- Adds
-f, --format <fmt>to localprofile list(defaulting to the existing human/prose output path). - Emits structured rows for non-
tableformats, including connected runtime profiles plus disconnected saved aliases/defaults. - Adds new unit tests covering
-f jsonoutput for empty and mixed connected/disconnected cases.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/cli.ts | Adds -f/--format support to local profile list and routes non-table formats through shared structured output. |
| src/cli.test.ts | Adds unit tests for JSON structured output for local profile list. |
Suppressed comments (1)
src/cli.test.ts:1779
- This structured-row test verifies JSON output but not YAML. Adding a YAML assertion here would ensure the shared output path produces the same rows across the two primary structured formats referenced in #175.
await program.parseAsync(['node', 'webcmd', 'profile', 'list', '-f', 'json']);
const output = stdoutSpy.mock.calls.flat().join('\n');
expect(JSON.parse(output)).toEqual([
{ contextId: 'work', alias: 'work', default: true, connected: true, runtimeVersion: '1.2.3' },
{ contextId: 'gone', alias: 'archived', default: false, connected: false, runtimeVersion: null },
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+1811
to
+1813
| // Aligns with the hosted `profile list` row shape (`default`); local rows also | ||
| // carry `connected`/`runtimeVersion` since Cloak profiles are live runtime | ||
| // connections, not persisted Cloud records. |
Comment on lines
+1743
to
+1749
| const program = createProgram('', ''); | ||
|
|
||
| await program.parseAsync(['node', 'webcmd', 'profile', 'list', '-f', 'json']); | ||
|
|
||
| const output = stdoutSpy.mock.calls.flat().join('\n'); | ||
| expect(JSON.parse(output)).toEqual([]); | ||
| }); |
adikulkarni006
approved these changes
Aug 17, 2026
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
Partial slice of #175.
Local
profile listrejected-fentirely and only printed prose,while hosted
profile listalready supports-f json|yaml|csv|md(
src/hosted/runner.ts) — the same command name behaving differentlybetween modes with no indication why. #175 explicitly calls out
"align local profile list with hosted profile-list formatting."
Changes
-f, --format(defaulttable, prose output unchanged).path. Row shape aligns with hosted's where the concept overlaps
(
default), plus locally-meaningful fields hosted doesn't have(
connected,runtimeVersion) since Cloak profiles are liveruntime connections, not persisted Cloud records.
included as
connected: falserows so the structured view doesn'tsilently drop information the text view shows.
[]fornon-table formats rather than swallowing output, mirroring the
existing
adapter statusempty-list convention.Scope note
Same slice-of-#175 approach as the
validateanddaemon statusPRs.Test plan
src/cli.test.ts:-f jsonwith no profiles(→
[]), and with a connected profile + a disconnected savedalias + a disconnected default (→ structured rows).
npx tsc --noEmitclean.npx vitest run --project unit src/cli.test.ts— 104/104 pass.webcmd profile list -f json/webcmd profile list.