Skip to content

Commit 4171d88

Browse files
swap from using '@' prefixes for file and stdin inputs for JSON flags: check file suffixes instead, read from stdin on '-', update unit tests
1 parent 845bd1c commit 4171d88

12 files changed

Lines changed: 195 additions & 76 deletions

File tree

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -206,16 +206,16 @@ Many flags accept JSON in three forms:
206206
```bash
207207
pc index vector fetch --index-name my-index --namespace demo --ids '["vec-1","vec-2"]'
208208
```
209-
- From a file with `@path`:
209+
- From a file ending in `.json` or `.jsonl`:
210210
```bash
211-
pc index vector upsert --index-name my-index --namespace demo --body @./vectors.jsonl
211+
pc index vector upsert --index-name my-index --namespace demo --body ./vectors.jsonl
212212
```
213-
- From stdin with `@-`:
213+
- From stdin with `-`:
214214
```bash
215-
cat vectors.jsonl | pc index vector upsert --index-name my-index --namespace demo --body @-
215+
cat vectors.jsonl | pc index vector upsert --index-name my-index --namespace demo --body -
216216
```
217217

218-
NOTE: stdin can only be used with one flag at a time.
218+
Stdin can only be used with one flag at a time.
219219

220220
## Data plane quickstart (end-to-end)
221221

@@ -263,7 +263,7 @@ Alternatively, you can upsert using a JSON object with a `vectors` array:
263263
pc index create --name my-index --dimension 3 --metric cosine --cloud aws --region us-east-1
264264

265265
# Upsert vectors into the index via JSON or JSONL
266-
pc index vector upsert --index-name my-index --namespace my-namespace --body @./vectors.jsonl
266+
pc index vector upsert --index-name my-index --namespace my-namespace --body ./vectors.jsonl
267267

268268
# List vectors
269269
pc index vector list --index-name my-index --namespace my-namespace

internal/pkg/cli/command/index/describe_stats.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,20 @@ func NewDescribeIndexStatsCmd() *cobra.Command {
3030
Return index statistics including dimension, total vector count, namespaces summary, and metadata field counts.
3131
Use an optional metadata filter to restrict the scope of counts.
3232
33-
JSON input may be inline, loaded from a file with @path, or read from stdin with @-.
33+
JSON input may be inline, loaded from ./file.json, or read from stdin with '-'.
3434
`),
3535
Example: help.Examples(`
3636
pc index describe-stats --index-name "index-name"
37-
pc index describe-stats --index-name "index-name" --filter '{"k":"v"}'
38-
pc index describe-stats --index-name "index-name" --filter @./filter.json
37+
pc index describe-stats --index-name "index-name" --filter '{"genre":{"$eq":"rock"}}'
38+
pc index describe-stats --index-name "index-name" --filter ./filter.json
3939
`),
4040
Run: func(cmd *cobra.Command, args []string) {
4141
runDescribeIndexStatsCmd(cmd.Context(), options)
4242
},
4343
}
4444

4545
cmd.Flags().StringVarP(&options.indexName, "index-name", "n", "", "name of index to describe stats for")
46-
cmd.Flags().VarP(&options.filter, "filter", "f", "metadata filter to apply to the operation (inline JSON, @path.json, or @- for stdin; max size: see PC_CLI_MAX_JSON_BYTES)")
46+
cmd.Flags().VarP(&options.filter, "filter", "f", "metadata filter to apply to the operation (inline JSON, ./path.json, or '-' for stdin; max size: see PC_CLI_MAX_JSON_BYTES)")
4747
cmd.Flags().BoolVar(&options.json, "json", false, "output as JSON")
4848
_ = cmd.MarkFlagRequired("index-name")
4949

internal/pkg/cli/command/index/vector/cmd.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ func NewVectorCmd() *cobra.Command {
2424
Short: "Work with data in an index",
2525
Long: vectorHelp,
2626
Example: help.Examples(`
27-
pc index vector upsert --index-name my-index --body @./vectors.json
27+
pc index vector upsert --index-name my-index --body ./vectors.json
2828
pc index vector list --index-name my-index --namespace my-namespace
2929
pc index vector fetch --index-name my-index --ids '["123","456"]'
3030
pc index vector update --index-name my-index --id doc-123 --metadata '{"genre":"sci-fi"}'
31-
pc index vector query --index-name my-index --vector @./vector.json --top-k 10
31+
pc index vector query --index-name my-index --vector ./vector.json --top-k 10
3232
pc index vector delete --index-name my-index --ids doc-123
3333
`),
3434
GroupID: help.GROUP_INDEX_DATA.ID,

internal/pkg/cli/command/index/vector/delete.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ func NewDeleteVectorsCmd() *cobra.Command {
3131
Delete vectors from an index namespace by explicit IDs, a metadata filter, or delete all vectors in the namespace.
3232
3333
Provide exactly one of: --ids, --filter, or --all-vectors.
34-
--ids and --filter flags support inline JSON, @path.json, or @- to read from stdin.
34+
--ids and --filter flags support inline JSON, ./path.json, or '-' to read from stdin.
3535
`),
3636
Example: help.Examples(`
3737
pc index vector delete --index-name my-index --namespace my-namespace --ids my-id
@@ -46,7 +46,7 @@ func NewDeleteVectorsCmd() *cobra.Command {
4646
cmd.Flags().StringVarP(&options.indexName, "index-name", "n", "", "name of the index to delete vectors from")
4747
cmd.Flags().StringVar(&options.namespace, "namespace", "__default__", "namespace to delete vectors from")
4848
cmd.Flags().Var(&options.ids, "ids", "IDs of the vectors to delete")
49-
cmd.Flags().Var(&options.filter, "filter", "filter to delete the vectors with (inline JSON, @path.json, or @- for stdin; max size: see PC_CLI_MAX_JSON_BYTES)")
49+
cmd.Flags().Var(&options.filter, "filter", "filter to delete the vectors with (inline JSON, ./path.json, or '-' for stdin; max size: see PC_CLI_MAX_JSON_BYTES)")
5050
cmd.Flags().BoolVar(&options.deleteAllVectors, "all-vectors", false, "delete all vectors from the namespace")
5151
cmd.Flags().BoolVar(&options.json, "json", false, "output as JSON")
5252

internal/pkg/cli/command/index/vector/fetch.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,31 +47,31 @@ func NewFetchCmd() *cobra.Command {
4747
Fetch vectors from an index either by explicit IDs or by a metadata filter with optional pagination.
4848
4949
When using --ids, pagination flags (--limit, --pagination-token) are not applicable.
50-
JSON inputs may be inline, loaded from a file with @path, or read from stdin with @-.
50+
JSON inputs may be inline, loaded from ./file.json[l], or read from stdin with '-'.
5151
A --body payload can supply ids, filter, limit, and pagination_token fields. Flags win if both are provided.
5252
`),
5353
Example: help.Examples(`
5454
pc index vector fetch --index-name my-index --ids '["123","456","789"]'
55-
pc index vector fetch --index-name my-index --ids @./ids.json
55+
pc index vector fetch --index-name my-index --ids ./ids.json
5656
57-
pc index vector fetch --index-name my-index --filter '{"key": "value"}'
58-
pc index vector fetch --index-name my-index --filter @./filter.json
57+
pc index vector fetch --index-name my-index --filter '{"genre":{"$eq":"rock"}}'
58+
pc index vector fetch --index-name my-index --filter ./filter.json
5959
60-
pc index vector fetch --index-name my-index --body @./fetch.json
61-
cat fetch.json | pc index vector fetch --index-name my-index --body @-
60+
pc index vector fetch --index-name my-index --body ./fetch.json
61+
cat fetch.json | pc index vector fetch --index-name my-index --body -
6262
`),
6363
Run: func(cmd *cobra.Command, args []string) {
6464
runFetchCmd(cmd.Context(), options)
6565
},
6666
}
6767

68-
cmd.Flags().VarP(&options.ids, "ids", "i", "IDs of vectors to fetch (inline JSON array, @path.json, or @- for stdin; max size: see PC_CLI_MAX_JSON_BYTES)")
69-
cmd.Flags().VarP(&options.filter, "filter", "f", "metadata filter to apply to the fetch (inline JSON, @path.json, or @- for stdin; max size: see PC_CLI_MAX_JSON_BYTES)")
68+
cmd.Flags().VarP(&options.ids, "ids", "i", "IDs of vectors to fetch (inline JSON array, ./path.json, or '-' for stdin; max size: see PC_CLI_MAX_JSON_BYTES)")
69+
cmd.Flags().VarP(&options.filter, "filter", "f", "metadata filter to apply to the fetch (inline JSON, ./path.json, or '-' for stdin; max size: see PC_CLI_MAX_JSON_BYTES)")
7070
cmd.Flags().StringVarP(&options.indexName, "index-name", "n", "", "name of the index to fetch from")
7171
cmd.Flags().StringVar(&options.namespace, "namespace", "__default__", "namespace to fetch from")
7272
cmd.Flags().Uint32VarP(&options.limit, "limit", "l", 0, "maximum number of vectors to fetch")
7373
cmd.Flags().StringVarP(&options.paginationToken, "pagination-token", "p", "", "pagination token to continue a previous listing operation")
74-
cmd.Flags().StringVar(&options.body, "body", "", "request body JSON (inline, @path.json, or @- for stdin; only one argument may use stdin; max size: see PC_CLI_MAX_JSON_BYTES)")
74+
cmd.Flags().StringVar(&options.body, "body", "", "request body JSON (inline, ./path.json, or '-' for stdin; only one argument may use stdin; max size: see PC_CLI_MAX_JSON_BYTES)")
7575
cmd.Flags().BoolVarP(&options.json, "json", "j", false, "output as JSON")
7676

7777
cmd.MarkFlagsMutuallyExclusive("ids", "filter")

internal/pkg/cli/command/index/vector/query.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func NewQueryCmd() *cobra.Command {
5656
Use --top-k to control result count and --include-values/--include-metadata to enrich results.
5757
An optional metadata filter can be used to filter the results.
5858
59-
JSON inputs may be inline, loaded from a file with @path, or read from stdin with @-.
59+
JSON inputs may be inline, loaded from ./file.json[l], or read from stdin with '-'.
6060
6161
When providing sparse values, both --sparse-indices and --sparse-values must be present.
6262
A --body payload can pass id, vector, sparse_values, filter, top_k, include_values, and include_metadata.
@@ -65,15 +65,15 @@ func NewQueryCmd() *cobra.Command {
6565
pc index vector query --index-name my-index --id doc-123 --top-k 10 --include-metadata
6666
6767
pc index vector query --index-name my-index --vector '[0.1, 0.2, 0.3]' --top-k 25
68-
pc index vector query --index-name my-index --vector @./vector.json --top-k 25 --include-metadata
69-
jq -c '.embedding' doc.json | pc index vector query --index-name my-index --vector @- --top-k 20
68+
pc index vector query --index-name my-index --vector ./vector.json --top-k 25 --include-metadata
69+
jq -c '.embedding' doc.json | pc index vector query --index-name my-index --vector - --top-k 20
7070
71-
pc index vector query --index-name my-index --sparse-indices @./indices.json --sparse-values @./values.json --top-k 15
71+
pc index vector query --index-name my-index --sparse-indices ./indices.json --sparse-values ./values.json --top-k 15
7272
73-
pc index vector query --index-name my-index --vector @./vector.json --filter '{"genre":"sci-fi"}' --include-metadata
73+
pc index vector query --index-name my-index --vector ./vector.json --filter '{"genre":{"$eq":"sci-fi"}}' --include-metadata
7474
75-
pc index vector query --index-name my-index --body @./query.json
76-
cat query.json | pc index vector query --index-name my-index --body @-
75+
pc index vector query --index-name my-index --body ./query.json
76+
cat query.json | pc index vector query --index-name my-index --body -
7777
`),
7878
Run: func(cmd *cobra.Command, args []string) {
7979
runQueryCmd(cmd.Context(), options)
@@ -83,14 +83,14 @@ func NewQueryCmd() *cobra.Command {
8383
cmd.Flags().StringVarP(&options.indexName, "index-name", "n", "", "name of the index to query")
8484
cmd.Flags().StringVar(&options.namespace, "namespace", "__default__", "index namespace to query")
8585
cmd.Flags().Uint32VarP(&options.topK, "top-k", "k", 10, "maximum number of results to return")
86-
cmd.Flags().VarP(&options.filter, "filter", "f", "metadata filter to apply to the query (inline JSON, @path.json, or @- for stdin; max size: see PC_CLI_MAX_JSON_BYTES)")
86+
cmd.Flags().VarP(&options.filter, "filter", "f", "metadata filter to apply to the query (inline JSON, ./path.json, or '-' for stdin; max size: see PC_CLI_MAX_JSON_BYTES)")
8787
cmd.Flags().BoolVar(&options.includeValues, "include-values", false, "include vector values in the query results")
8888
cmd.Flags().BoolVar(&options.includeMetadata, "include-metadata", false, "include metadata in the query results")
8989
cmd.Flags().StringVarP(&options.id, "id", "i", "", "ID of the vector to query against")
90-
cmd.Flags().VarP(&options.vector, "vector", "v", "vector values to query against (inline JSON array, @path.json, or @- for stdin; max size: see PC_CLI_MAX_JSON_BYTES)")
91-
cmd.Flags().Var(&options.sparseIndices, "sparse-indices", "sparse indices to query against (inline JSON array, @path.json, or @- for stdin; max size: see PC_CLI_MAX_JSON_BYTES)")
92-
cmd.Flags().Var(&options.sparseValues, "sparse-values", "sparse values to query against (inline JSON array, @path.json, or @- for stdin; max size: see PC_CLI_MAX_JSON_BYTES)")
93-
cmd.Flags().StringVar(&options.body, "body", "", "request body JSON (inline, @path.json, or @- for stdin; only one argument may use stdin; max size: see PC_CLI_MAX_JSON_BYTES)")
90+
cmd.Flags().VarP(&options.vector, "vector", "v", "vector values to query against (inline JSON array, ./path.json, or '-' for stdin; max size: see PC_CLI_MAX_JSON_BYTES)")
91+
cmd.Flags().Var(&options.sparseIndices, "sparse-indices", "sparse indices to query against (inline JSON array, ./path.json, or '-' for stdin; max size: see PC_CLI_MAX_JSON_BYTES)")
92+
cmd.Flags().Var(&options.sparseValues, "sparse-values", "sparse values to query against (inline JSON array, ./path.json, or '-' for stdin; max size: see PC_CLI_MAX_JSON_BYTES)")
93+
cmd.Flags().StringVar(&options.body, "body", "", "request body JSON (inline, ./path.json, or '-' for stdin; only one argument may use stdin; max size: see PC_CLI_MAX_JSON_BYTES)")
9494
cmd.Flags().BoolVar(&options.json, "json", false, "output as JSON")
9595

9696
_ = cmd.MarkFlagRequired("index-name")

internal/pkg/cli/command/index/vector/update.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,16 @@ func NewUpdateCmd() *cobra.Command {
5353
Update a single vector by ID (values, sparse values, metadata) or update metadata for all vectors matching a metadata filter.
5454
5555
Use --dry-run with --filter updates to preview how many records would be updated.
56-
JSON inputs may be inline, @file, or @- for stdin.
56+
JSON inputs may be inline, ./file.json[l], or read from stdin with '-'.
5757
A --body payload can supply id, values, sparse_values, metadata, filter, and dry_run fields.
5858
`),
5959
Example: help.Examples(`
6060
pc index vector update --index-name my-index --id doc-123 --values '[0.1, 0.2, 0.3]'
61-
pc index vector update --index-name my-index --id doc-123 --sparse-indices @./indices.json --sparse-values @./values.json
61+
pc index vector update --index-name my-index --id doc-123 --sparse-indices ./indices.json --sparse-values ./values.json
6262
pc index vector update --index-name my-index --id doc-123 --metadata '{"genre":"sci-fi"}'
63-
pc index vector update --index-name my-index --filter '{"genre":"sci-fi"}' --metadata '{"genre":"fantasy"}' --dry-run
64-
pc index vector update --index-name my-index --body @./update.json
65-
cat update.json | pc index vector update --index-name my-index --body @-
63+
pc index vector update --index-name my-index --filter '{"genre":{"$eq":"sci-fi"}}' --metadata '{"genre":"fantasy"}' --dry-run
64+
pc index vector update --index-name my-index --body ./update.json
65+
cat update.json | pc index vector update --index-name my-index --body -
6666
`),
6767
Run: func(cmd *cobra.Command, args []string) {
6868
runUpdateCmd(cmd.Context(), options)
@@ -72,13 +72,13 @@ func NewUpdateCmd() *cobra.Command {
7272
cmd.Flags().StringVarP(&options.indexName, "index-name", "n", "", "name of the index to update")
7373
cmd.Flags().StringVar(&options.namespace, "namespace", "__default__", "namespace to update the vector in")
7474
cmd.Flags().StringVar(&options.id, "id", "", "ID of the vector to update")
75-
cmd.Flags().Var(&options.values, "values", "values to update the vector with (inline JSON array, @path.json, or @- for stdin; max size: see PC_CLI_MAX_JSON_BYTES)")
76-
cmd.Flags().Var(&options.sparseIndices, "sparse-indices", "sparse indices to update the vector with (inline JSON array, @path.json, or @- for stdin; max size: see PC_CLI_MAX_JSON_BYTES)")
77-
cmd.Flags().Var(&options.sparseValues, "sparse-values", "sparse values to update the vector with (inline JSON array, @path.json, or @- for stdin; max size: see PC_CLI_MAX_JSON_BYTES)")
78-
cmd.Flags().Var(&options.metadata, "metadata", "metadata to update the vector with (inline JSON, @path.json, or @- for stdin; max size: see PC_CLI_MAX_JSON_BYTES)")
79-
cmd.Flags().Var(&options.filter, "filter", "filter to update the vectors with (inline JSON, @path.json, or @- for stdin; max size: see PC_CLI_MAX_JSON_BYTES)")
75+
cmd.Flags().Var(&options.values, "values", "values to update the vector with (inline JSON array, ./path.json, or '-' for stdin; max size: see PC_CLI_MAX_JSON_BYTES)")
76+
cmd.Flags().Var(&options.sparseIndices, "sparse-indices", "sparse indices to update the vector with (inline JSON array, ./path.json, or '-' for stdin; max size: see PC_CLI_MAX_JSON_BYTES)")
77+
cmd.Flags().Var(&options.sparseValues, "sparse-values", "sparse values to update the vector with (inline JSON array, ./path.json, or '-' for stdin; max size: see PC_CLI_MAX_JSON_BYTES)")
78+
cmd.Flags().Var(&options.metadata, "metadata", "metadata to update the vector with (inline JSON, ./path.json, or '-' for stdin; max size: see PC_CLI_MAX_JSON_BYTES)")
79+
cmd.Flags().Var(&options.filter, "filter", "filter to update the vectors with (inline JSON, ./path.json, or '-' for stdin; max size: see PC_CLI_MAX_JSON_BYTES)")
8080
cmd.Flags().BoolVar(&options.dryRun, "dry-run", false, "do not update the vectors, just return the number of vectors that would be updated")
81-
cmd.Flags().StringVar(&options.body, "body", "", "request body JSON (inline, @path.json, or @- for stdin; only one argument may use stdin; max size: see PC_CLI_MAX_JSON_BYTES)")
81+
cmd.Flags().StringVar(&options.body, "body", "", "request body JSON (inline, ./path.json, or '-' for stdin; only one argument may use stdin; max size: see PC_CLI_MAX_JSON_BYTES)")
8282
cmd.Flags().BoolVar(&options.json, "json", false, "output as JSON")
8383

8484
_ = cmd.MarkFlagRequired("index-name")

internal/pkg/cli/command/index/vector/upsert.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,14 @@ func NewUpsertCmd() *cobra.Command {
4545
Upsert vectors into an index namespace from a JSON or JSONL payload.
4646
4747
The request --body may be a JSON object containing "vectors": [...] or a JSONL stream of Vector objects.
48-
Control batch size with --batch-size. Bodies can be inline JSON, loaded via @file, or read from stdin with @-.
48+
Control batch size with --batch-size. Bodies can be inline JSON, loaded from ./file.json[l], or read from stdin with '-'.
4949
5050
Body schema: UpsertBody (vectors shaped like pinecone.Vector: https://pkg.go.dev/github.com/pinecone-io/go-pinecone/v5/pinecone#Vector)
5151
`),
5252
Example: help.Examples(`
53-
pc index vector upsert --index-name my-index --namespace my-namespace --body @./vectors.json
54-
pc index vector upsert --index-name my-index --namespace my-namespace --body @./vectors.jsonl
55-
cat payload.json | pc index vector upsert --index-name my-index --namespace my-namespace --body @-
53+
pc index vector upsert --index-name my-index --namespace my-namespace --body ./vectors.json
54+
pc index vector upsert --index-name my-index --namespace my-namespace --body ./vectors.jsonl
55+
cat payload.json | pc index vector upsert --index-name my-index --namespace my-namespace --body -
5656
`),
5757
Run: func(cmd *cobra.Command, args []string) {
5858
runUpsertCmd(cmd.Context(), options)
@@ -61,7 +61,7 @@ func NewUpsertCmd() *cobra.Command {
6161

6262
cmd.Flags().StringVarP(&options.indexName, "index-name", "n", "", "name of index to upsert into")
6363
cmd.Flags().StringVar(&options.namespace, "namespace", "__default__", "namespace to upsert into")
64-
cmd.Flags().StringVar(&options.body, "body", "", "request body JSON or JSONL (inline, @path.json[l], or @- for stdin; only one argument may use stdin; max size: see PC_CLI_MAX_JSON_BYTES)")
64+
cmd.Flags().StringVar(&options.body, "body", "", "request body JSON or JSONL (inline, ./path.json[l], or '-' for stdin; only one argument may use stdin; max size: see PC_CLI_MAX_JSON_BYTES)")
6565
cmd.Flags().IntVarP(&options.batchSize, "batch-size", "b", 500, "size of batches to upsert (default: 500)")
6666
cmd.Flags().BoolVar(&options.json, "json", false, "output as JSON")
6767
_ = cmd.MarkFlagRequired("index-name")

0 commit comments

Comments
 (0)