Skip to content

Commit 42e1039

Browse files
Fix --quiet --json combination suppressing command output (#72)
## Problem Currently, passing `--quiet --json` to commands ends up suppressing the expected JSON output due to `pcio`. We're going to most likely remove `pcio` entirely in a future PR. ## Solution Make sure `--quiet --json` flag comination doesn't suppress command output, add `pcio.PrintJSON` that writes directly to stdout and replace `pcio.Println` across commands. ## Type of Change - [X] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] This change requires a documentation update - [ ] Infrastructure change (CI configs, etc) - [ ] Non-code change (docs, etc) - [ ] None of the above: (explain here) ## Test Plan Run commands with `--json --quiet` and make sure you're seeing JSON in stdout. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Low risk: output-path change only, routing JSON to stdout regardless of quiet mode; potential risk is minor formatting/stream changes for scripts expecting previous suppression behavior. > > **Overview** > Fixes the `--quiet --json` combination by adding `pcio.PrintJSON` (always writes to stdout) and switching JSON output paths across CLI commands from `pcio.Println` to `pcio.PrintJSON`. > > This ensures machine-readable JSON is emitted even in quiet mode for commands like API key, auth, backup restore, collections, indexes/namespaces/records/vectors, organizations, projects, and target, and adds unit tests covering `PrintJSON` vs `Println` behavior under quiet mode. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 07d74a1. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent a124bc8 commit 42e1039

39 files changed

Lines changed: 110 additions & 38 deletions

internal/pkg/cli/command/apiKey/create.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ func NewCreateApiKeyCmd() *cobra.Command {
9696

9797
if options.json {
9898
json := text.IndentJSON(keyWithSecret)
99-
pcio.Println(json)
99+
pcio.PrintJSON(json)
100100
} else {
101101
msg.SuccessMsg("API key %s created successfully.\n", style.Emphasis(keyWithSecret.Key.Name))
102102
presenters.PrintDescribeAPIKeyWithSecretTable(keyWithSecret)

internal/pkg/cli/command/apiKey/describe.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func NewDescribeAPIKeyCmd() *cobra.Command {
3939

4040
if options.json {
4141
json := text.IndentJSON(apiKey)
42-
pcio.Println(json)
42+
pcio.PrintJSON(json)
4343
} else {
4444
presenters.PrintDescribeAPIKeyTable(apiKey)
4545
}

internal/pkg/cli/command/apiKey/list.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ func NewListKeysCmd() *cobra.Command {
6565

6666
if options.json {
6767
json := text.IndentJSON(sortedKeys)
68-
pcio.Println(json)
68+
pcio.PrintJSON(json)
6969
} else {
7070
printTable(sortedKeys)
7171
}

internal/pkg/cli/command/apiKey/update.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func NewUpdateAPIKeyCmd() *cobra.Command {
5050

5151
if options.json {
5252
json := text.IndentJSON(apiKey)
53-
pcio.Println(json)
53+
pcio.PrintJSON(json)
5454
return
5555
}
5656

internal/pkg/cli/command/auth/configure.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ func Run(ctx context.Context, io IO, opts configureCmdOptions) {
240240
defaultAPIKey := secrets.DefaultAPIKey.Get()
241241
targetContext.DefaultAPIKey = presenters.MaskHeadTail(defaultAPIKey, 4, 4)
242242
json := text.IndentJSON(targetContext)
243-
pcio.Println(json)
243+
pcio.PrintJSON(json)
244244
return
245245
}
246246

internal/pkg/cli/command/auth/local_keys_list.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func NewListLocalKeysCmd() *cobra.Command {
4242
if options.json {
4343
maskedMap := maskForJSON(managedKeys, options.reveal)
4444
json := text.IndentJSON(maskedMap)
45-
pcio.Println(json)
45+
pcio.PrintJSON(json)
4646
} else {
4747
printTable(managedKeys, options.reveal)
4848
}

internal/pkg/cli/command/auth/local_keys_prune.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ func confirmPruneKeys(plan []planItem, options pruneLocalKeysCmdOptions) (bool,
215215
func printDryRunPlan(plan []planItem, options pruneLocalKeysCmdOptions) {
216216
if options.json {
217217
json := text.IndentJSON(plan)
218-
pcio.Println(json)
218+
pcio.PrintJSON(json)
219219
} else {
220220
for _, key := range plan {
221221
if key.onServer {

internal/pkg/cli/command/auth/status.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ func runAuthStatus(cmd *cobra.Command, options authStatusCmdOptions) error {
9999

100100
if options.json {
101101
json := text.IndentJSON(authStatus)
102-
pcio.Println(json)
102+
pcio.PrintJSON(json)
103103
return nil
104104
}
105105

internal/pkg/cli/command/backup/restore/cmd.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ func runRestoreJobCmd(ctx context.Context, svc RestoreJobService, options restor
113113
}
114114

115115
if options.json {
116-
pcio.Println(text.IndentJSON(resp))
116+
pcio.PrintJSON(text.IndentJSON(resp))
117117
return nil
118118
}
119119

internal/pkg/cli/command/backup/restore/describe.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ func runDescribeRestoreJobCmd(ctx context.Context, svc RestoreJobService, option
5858
}
5959

6060
if options.json {
61-
pcio.Println(text.IndentJSON(resp))
61+
pcio.PrintJSON(text.IndentJSON(resp))
6262
} else {
6363
presenters.PrintRestoreJob(resp)
6464
}

0 commit comments

Comments
 (0)