Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion internal/pkg/cli/command/apiKey/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func NewCreateApiKeyCmd() *cobra.Command {

if options.json {
json := text.IndentJSON(keyWithSecret)
pcio.Println(json)
pcio.PrintJSON(json)
} else {
msg.SuccessMsg("API key %s created successfully.\n", style.Emphasis(keyWithSecret.Key.Name))
presenters.PrintDescribeAPIKeyWithSecretTable(keyWithSecret)
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/cli/command/apiKey/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func NewDescribeAPIKeyCmd() *cobra.Command {

if options.json {
json := text.IndentJSON(apiKey)
pcio.Println(json)
pcio.PrintJSON(json)
} else {
presenters.PrintDescribeAPIKeyTable(apiKey)
}
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/cli/command/apiKey/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func NewListKeysCmd() *cobra.Command {

if options.json {
json := text.IndentJSON(sortedKeys)
pcio.Println(json)
pcio.PrintJSON(json)
} else {
printTable(sortedKeys)
}
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/cli/command/apiKey/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func NewUpdateAPIKeyCmd() *cobra.Command {

if options.json {
json := text.IndentJSON(apiKey)
pcio.Println(json)
pcio.PrintJSON(json)
return
}

Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/cli/command/auth/configure.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ func Run(ctx context.Context, io IO, opts configureCmdOptions) {
defaultAPIKey := secrets.DefaultAPIKey.Get()
targetContext.DefaultAPIKey = presenters.MaskHeadTail(defaultAPIKey, 4, 4)
json := text.IndentJSON(targetContext)
pcio.Println(json)
pcio.PrintJSON(json)
return
}

Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/cli/command/auth/local_keys_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func NewListLocalKeysCmd() *cobra.Command {
if options.json {
maskedMap := maskForJSON(managedKeys, options.reveal)
json := text.IndentJSON(maskedMap)
pcio.Println(json)
pcio.PrintJSON(json)
} else {
printTable(managedKeys, options.reveal)
}
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/cli/command/auth/local_keys_prune.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ func confirmPruneKeys(plan []planItem, options pruneLocalKeysCmdOptions) (bool,
func printDryRunPlan(plan []planItem, options pruneLocalKeysCmdOptions) {
if options.json {
json := text.IndentJSON(plan)
pcio.Println(json)
pcio.PrintJSON(json)
} else {
for _, key := range plan {
if key.onServer {
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/cli/command/auth/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func runAuthStatus(cmd *cobra.Command, options authStatusCmdOptions) error {

if options.json {
json := text.IndentJSON(authStatus)
pcio.Println(json)
pcio.PrintJSON(json)
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/cli/command/backup/restore/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func runRestoreJobCmd(ctx context.Context, svc RestoreJobService, options restor
}

if options.json {
pcio.Println(text.IndentJSON(resp))
pcio.PrintJSON(text.IndentJSON(resp))
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/cli/command/backup/restore/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func runDescribeRestoreJobCmd(ctx context.Context, svc RestoreJobService, option
}

if options.json {
pcio.Println(text.IndentJSON(resp))
pcio.PrintJSON(text.IndentJSON(resp))
} else {
presenters.PrintRestoreJob(resp)
}
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/cli/command/backup/restore/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func runListRestoreJobsCmd(ctx context.Context, svc RestoreJobService, options l
}

if options.json {
pcio.Println(text.IndentJSON(resp))
pcio.PrintJSON(text.IndentJSON(resp))
} else {
presenters.PrintRestoreJobList(resp)
}
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/cli/command/collection/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func NewCreateCollectionCmd() *cobra.Command {

if options.json {
json := text.IndentJSON(collection)
pcio.Println(json)
pcio.PrintJSON(json)
} else {
describeCommand := pcio.Sprintf("pc collection describe --name %s", collection.Name)
msg.SuccessMsg("Collection %s created successfully. Run %s to check status. \n\n", style.Emphasis(collection.Name), style.Code(describeCommand))
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/cli/command/collection/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func NewDescribeCollectionCmd() *cobra.Command {

if options.json {
json := text.IndentJSON(collection)
pcio.Println(json)
pcio.PrintJSON(json)
} else {
presenters.PrintDescribeCollectionTable(collection)
}
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/cli/command/collection/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func NewListCollectionsCmd() *cobra.Command {

if options.json {
json := text.IndentJSON(collections)
pcio.Println(json)
pcio.PrintJSON(json)
} else {
printTable(collections)
}
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/cli/command/index/configure.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ func runConfigureIndexCmd(ctx context.Context, cmd *cobra.Command, options confi

if options.json {
json := text.IndentJSON(idx)
pcio.Println(json)
pcio.PrintJSON(json)
return
}

Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/cli/command/index/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ func runCreateIndexCmd(ctx context.Context, cmd *cobra.Command, service CreateIn
func renderSuccessOutput(idx *pinecone.Index, options createIndexOptions) {
if options.json {
json := text.IndentJSON(idx)
pcio.Println(json)
pcio.PrintJSON(json)
return
}

Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/cli/command/index/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func NewDescribeCmd() *cobra.Command {

if options.json {
json := text.IndentJSON(idx)
pcio.Println(json)
pcio.PrintJSON(json)
} else {
presenters.PrintDescribeIndexTable(idx)
}
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/cli/command/index/describe_stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func runDescribeIndexStatsCmd(ctx context.Context, options describeIndexStatsCmd

if options.json {
json := text.IndentJSON(resp)
pcio.Println(json)
pcio.PrintJSON(json)
} else {
presenters.PrintDescribeIndexStatsTable(resp)
}
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/cli/command/index/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func NewListCmd() *cobra.Command {

if options.json {
json := text.IndentJSON(idxs)
pcio.Println(json)
pcio.PrintJSON(json)
} else {
printTable(idxs, options.wide)
}
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/cli/command/index/namespace/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func runCreateNamespaceCmd(ctx context.Context, ic NamespaceService, options cre

if options.json {
json := text.IndentJSON(ns)
pcio.Println(json)
pcio.PrintJSON(json)
} else {
msg.SuccessMsg("Namespace %s created successfully.", options.name)
presenters.PrintDescribeNamespaceTable(ns)
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/cli/command/index/namespace/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func runDescribeNamespaceCmd(ctx context.Context, ic NamespaceService, options d

if options.json {
json := text.IndentJSON(ns)
pcio.Println(json)
pcio.PrintJSON(json)
} else {
presenters.PrintDescribeNamespaceTable(ns)
}
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/cli/command/index/namespace/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func runListNamespaceCmd(ctx context.Context, ic NamespaceService, options listN

if options.json {
json := text.IndentJSON(resp)
pcio.Println(json)
pcio.PrintJSON(json)
} else {
printTable(resp)
}
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/cli/command/index/record/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ func runSearchCmd(ctx context.Context, ic RecordService, options searchCmdOption
}

if options.json {
pcio.Println(text.IndentJSON(resp))
pcio.PrintJSON(text.IndentJSON(resp))
} else {
presenters.PrintSearchRecordsTable(resp)
}
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/cli/command/index/record/upsert.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ func runUpsertCmd(ctx context.Context, ic RecordService, options upsertCmdOption
"records": len(batch),
"namespace": options.namespace,
}
pcio.Println(text.IndentJSON(summary))
pcio.PrintJSON(text.IndentJSON(summary))
} else {
msg.SuccessMsg("Upserted %d records into namespace %s (batch %d of %d)", len(batch), options.namespace, i+1, len(batches))
}
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/cli/command/index/vector/fetch.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ func runFetchCmd(ctx context.Context, options fetchCmdOptions) {
func printFetchVectorsResults(results *presenters.FetchVectorsResults, options fetchCmdOptions) {
if options.json {
json := text.IndentJSON(results)
pcio.Println(json)
pcio.PrintJSON(json)
} else {
presenters.PrintFetchVectorsTable(results)
}
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/cli/command/index/vector/list_vectors.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func runListVectorsCmd(ctx context.Context, options listVectorsCmdOptions) {

if options.json {
json := text.IndentJSON(resp)
pcio.Println(json)
pcio.PrintJSON(json)
} else {
presenters.PrintListVectorsTable(resp)
}
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/cli/command/index/vector/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ func runQueryCmd(ctx context.Context, options queryCmdOptions) {

if options.json {
json := text.IndentJSON(queryResponse)
pcio.Println(json)
pcio.PrintJSON(json)
} else {
presenters.PrintQueryVectorsTable(queryResponse)
}
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/cli/command/index/vector/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ func runUpdateCmd(ctx context.Context, options updateCmdOptions) {
presenters.PrintUpdateVectorsByMetadataTable(resp)
} else {
json := text.IndentJSON(resp)
pcio.Println(json)
pcio.PrintJSON(json)
}
return
}
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/cli/command/index/vector/upsert.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ func runUpsertCmd(ctx context.Context, options upsertCmdOptions) {
} else {
if options.json {
json := text.IndentJSON(resp)
pcio.Println(json)
pcio.PrintJSON(json)
} else {
msg.SuccessMsg("Upserted %d vectors into namespace %s (batch %d of %d)", len(batch), options.namespace, i+1, len(batches))
}
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/cli/command/organization/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func NewDescribeOrganizationCmd() *cobra.Command {

if options.json {
json := text.IndentJSON(org)
pcio.Println(json)
pcio.PrintJSON(json)
} else {
presenters.PrintDescribeOrganizationTable(org)
}
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/cli/command/organization/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func NewListOrganizationsCmd() *cobra.Command {

if options.json {
json := text.IndentJSON(orgs)
pcio.Println(json)
pcio.PrintJSON(json)
return
}

Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/cli/command/organization/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func NewUpdateOrganizationCmd() *cobra.Command {

if options.json {
json := text.IndentJSON(org)
pcio.Println(json)
pcio.PrintJSON(json)
return
}

Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/cli/command/project/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func NewCreateProjectCmd() *cobra.Command {

if options.json {
json := text.IndentJSON(proj)
pcio.Println(json)
pcio.PrintJSON(json)
return
}

Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/cli/command/project/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func NewDescribeProjectCmd() *cobra.Command {

if options.json {
json := text.IndentJSON(project)
pcio.Println(json)
pcio.PrintJSON(json)
} else {
presenters.PrintDescribeProjectTable(project)
}
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/cli/command/project/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func NewListProjectsCmd() *cobra.Command {

if options.json {
json := text.IndentJSON(projects)
pcio.Println(json)
pcio.PrintJSON(json)
} else {
printTable(projects)
}
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/cli/command/project/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func NewUpdateProjectCmd() *cobra.Command {

if options.json {
json := text.IndentJSON(project)
pcio.Println(json)
pcio.PrintJSON(json)
return
}

Expand Down
4 changes: 2 additions & 2 deletions internal/pkg/cli/command/target/target.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func NewTargetCmd() *cobra.Command {
defaultAPIKey := secrets.DefaultAPIKey.Get()
targetContext.DefaultAPIKey = presenters.MaskHeadTail(defaultAPIKey, 4, 4)
json := text.IndentJSON(targetContext)
pcio.Println(json)
pcio.PrintJSON(json)
return
}
log.Info().
Expand Down Expand Up @@ -260,7 +260,7 @@ func NewTargetCmd() *cobra.Command {
defaultAPIKey := secrets.DefaultAPIKey.Get()
targetContext.DefaultAPIKey = presenters.MaskHeadTail(defaultAPIKey, 4, 4)
json := text.IndentJSON(targetContext)
pcio.Println(json)
pcio.PrintJSON(json)
return
}

Expand Down
8 changes: 8 additions & 0 deletions internal/pkg/utils/pcio/print.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package pcio
import (
"fmt"
"io"
"os"
)

// The purpose of this package is to stub out the fmt package so that
Expand All @@ -15,6 +16,13 @@ func SetQuiet(q bool) {
quiet = q
}

// PrintJSON writes s to stdout regardless of quiet mode.
// Use this instead of Println when outputting structured JSON so that
// --quiet does not suppress machine-readable output.
func PrintJSON(s string) {
fmt.Fprintln(os.Stdout, s)
}

func Println(a ...any) {
if !quiet {
fmt.Println(a...)
Expand Down
Loading
Loading