Skip to content

Commit be93441

Browse files
docs(cli): object and array-of-object params do work via CLI (#646)
* docs(cli): object and array-of-object params do work via CLI The Operations API commands page asserted in three places that nested objects and arrays of objects cannot be passed as CLI arguments. That is not true, and the page contradicted itself: it showed a working `ids='["1","2","3"]'` array a few lines above the claim. `buildRequest()` in `bin/cliOperations.ts` JSON-parses every argument value, falling back to the raw string when the parse throws. Scalars, arrays, and objects all take that one path, so there is no basis for treating objects differently. `RAW_STRING_FIELDS` is `new Set(['ref'])` -- `ref` is the sole field exempted from the parse, so a numeric-looking git tag is not rewritten into a number. - State the actual parse rule once, at the top of Parameter Formatting, and note the `ref` exception. - Replace the "objects not supported" section with the `deploy_component` `credentials` array-of-objects example that `harper deploy setup=true` itself prints, plus the shell quoting rules that do apply. - Rewrite Limitations around real constraints: raw binary bodies, the OS argument-length cap, and secrets being visible in shell history, `ps`, and CI logs. Drop the false nested-JSON and array-of-objects entries, and the "file upload / streaming" entries that `deploy_component` and `get_backup` disprove. Closes #639 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * docs(cli): point application-template at HarperFast The `deploy_component` example linked to `github.com/HarperDB/application-template`, which now only resolves via the org-rename redirect. Verified `HarperFast/application-template` exists and is not archived (`gh repo view`), so the canonical URL is used directly. The other two GitHub URLs on the page (`user/repo`, `myorg/my-component`) are deliberate placeholders and are unchanged. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
1 parent 55228e7 commit be93441

1 file changed

Lines changed: 28 additions & 11 deletions

File tree

reference/cli/operations-api-commands.md

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ harper <operation> <parameter>=<value>
2626

2727
<!-- Source: Harper CLI source code (SUPPORTED_OPS and OP_ALIASES arrays) -->
2828

29-
The following operations are available through the CLI. Operations that require complex nested parameters or object structures are not supported via CLI and must be executed through the HTTP API.
29+
The following operations are available through the CLI. Argument values are JSON-parsed, so operations that take nested objects or arrays of objects work from the CLI as well. See [Parameter Formatting](#parameter-formatting) for how to quote them.
3030

3131
### Complete Operations List
3232

@@ -204,7 +204,7 @@ For comprehensive configuration options, see the [Configuration Reference](../co
204204
**Deploy a component**:
205205

206206
```bash
207-
harper deploy_component project=my-cool-app package=https://github.com/HarperDB/application-template
207+
harper deploy_component project=my-cool-app package=https://github.com/HarperFast/application-template
208208
```
209209

210210
**Get all components**:
@@ -282,6 +282,10 @@ For more information on Harper applications and components, see:
282282

283283
## Parameter Formatting
284284

285+
Every argument is split on the first `=` and the value is parsed as JSON. If the value is not valid JSON, it is passed through unchanged as a string. That single rule covers all of the parameter types below: `database=dev` fails to parse and stays the string `"dev"`, `json=true` parses to the boolean `true`, and `ids='["1","2"]'` parses to an array.
286+
287+
The one exception is `ref` (used by deploy-by-reference), which is always taken as a raw string so that a numeric-looking git tag such as `ref=1.0` is not rewritten into the number `1`.
288+
285289
### String Parameters
286290

287291
Simple string values can be passed directly:
@@ -300,10 +304,24 @@ harper search_by_id database=dev table=dog ids='["1","2","3"]'
300304

301305
### Object Parameters
302306

303-
Object parameters are not supported via CLI. For operations requiring complex nested objects, use:
307+
Objects and arrays of objects are supported. Pass them as single-quoted JSON:
308+
309+
```bash
310+
harper deploy_component project=my-app package=npm:@my-org/my-app@1.2.3 \
311+
credentials='[{"registry":"registry.my-org.com","secret":"deploy.my-app.registry.my-org.com"}]'
312+
```
304313

305-
- The [Operations API](../operations-api/overview.md) via HTTP
306-
- A custom script or tool
314+
`harper deploy setup=true` prints exactly this `credentials='[...]'` form as the command to run after it seals a registry or git token, so an array-of-objects argument is the normal path for private-package deploys rather than an edge case.
315+
316+
Quoting rules:
317+
318+
- Wrap the JSON in **single** quotes. Double quotes let the shell expand `$`, backticks, and history references inside the value; single quotes pass the JSON through intact.
319+
- The whole `key=value` pair is one shell argument, so no unescaped spaces outside the quotes. Compact JSON with no spaces after `:` and `,` avoids the problem entirely.
320+
- To embed a literal single quote inside the JSON, end the quoted run, escape it, and reopen: `'{"name":"O'\''Brien"}'`.
321+
322+
:::warning
323+
Command-line arguments are not private. Anything you type appears in shell history, in process listings (`ps`), and in CI job logs. Prefer a stored secret reference (the `secret` field above) or an environment variable over inlining a plaintext token in an argument.
324+
:::
307325

308326
### Boolean Parameters
309327

@@ -369,14 +387,13 @@ harper get_components \
369387

370388
## Limitations
371389

372-
The following operation types are **not supported** via CLI:
390+
Nested objects and arrays of objects are **not** a limitation; see [Object Parameters](#object-parameters). The real constraints are about what an argument value can carry:
373391

374-
- Operations requiring complex nested JSON structures
375-
- Operations with array-of-objects parameters
376-
- File upload operations
377-
- Streaming operations
392+
- **Raw binary bodies.** An argument value is text, so an operation whose request body is raw binary has no general CLI form. The two that need one have dedicated handling: `deploy_component` packages and uploads the current directory when `package` is omitted, and `get_backup` streams the snapshot to a file. Any other binary payload has to go over HTTP.
393+
- **Large payloads.** There is no way to feed an argument value from stdin or a file, and the operating system caps total argument length. Bulk data such as an inline `csv_data_load` is better sent over HTTP.
394+
- **Secrets on the command line.** Arguments are visible in shell history, `ps` output, and CI logs. Use a stored secret reference or an environment variable instead of an inline token.
378395

379-
For these operations, use the [Operations API](../operations-api/overview.md) directly via HTTP.
396+
For these cases, use the [Operations API](../operations-api/overview.md) directly via HTTP.
380397

381398
## See Also
382399

0 commit comments

Comments
 (0)