Skip to content

Shared command contracts ​

Part of Build an integration: shared APIs and infrastructure for adapter authors. For application usage, choose a library.

The shared engine supplies a consistent base; application compatibility adapters can retain native shapes and parsing. An application's own documentation remains the authority for its executable.

CommandInputOutput
listOptional metadata filter and presentation optionsProfile summaries, table/tree or selected full records
search <term>Metadata termMatching profile presentation
get <path> [property]Exact canonical path; optional propertyRecord or scalar
sourceSelected sourceSource provenance
write / syncDeclared writer/source selectors and supported intentPreview and diagnostics; no settings mutation
applyReviewed saved plan, same destination/policiesGuarded native commit or explicit refusal
write-statusExplicit destinationRead-only availability/revision inspection

The embedded example demonstrates actual list JSON and scalar selection output. For native table colours, credentials, write results and failure envelopes, follow an application's CLI documentation.

Help does not load settings. Default presentation masks secret values; --show-password requests explicit supported resolution. JSON is colour-free. Colour setup belongs in the executable bootstrap before the engine is imported. Common/source options and extension hooks are documented in build a CLI, with exact signatures in the reference.

Optional writer commands ​

Writer commands require host-provided factories and allowlisted source imports. Saving previews uses create-only semantics. Native apply rechecks source revision, process/lock availability and policies; the writing guide documents platform, backup and registry limitations.

Common input options ​

InputMeaning
--jsonColour-free JSON output
--tableTable presentation
--fullFull records for list
--recurse --jsonFolder tree with full records for list
--search <term>Search selection; with list, filter names and paths
--show-passwordExplicitly request supported credential resolution
--help / -hHelp without loading a source
--file <path>Pass a file selection to the source loader
--color / --no-colorColour preferences handled by the executable bootstrap

The source loader decides whether and how to use a file selection. Other native flags and sources discovery are supplied by application wrappers, not the base runner. search rejects --full and --recurse; list --recurse requires --json. Query search uses all supported metadata fields, while a list filter uses names/paths.

Captured commands and output ​

Use the complete saved program from the CLI quick start. These commands run that same file; they do not rely on a globally installed binary.

Exact property lookup ​

sh
npx tsx profile-cli.ts get Demo host --json
sh
node profile-cli.js get Demo host --json
sh
node profile-cli.mjs get Demo host --json
sh
node profile-cli.cjs get Demo host --json
text
"127.0.0.1"

Selected source ​

sh
npx tsx profile-cli.ts source --json
sh
node profile-cli.js source --json
sh
node profile-cli.mjs source --json
sh
node profile-cli.cjs source --json
text
{
  "id": "demo",
  "application": "demo"
}

Invalid option ​

sh
npx tsx profile-cli.ts list --unknown --json
sh
node profile-cli.js list --unknown --json
sh
node profile-cli.mjs list --unknown --json
sh
node profile-cli.cjs list --unknown --json

Standard error, exit code 1:

text
{"error":"Unknown option \"--unknown\""}
sh
npx tsx profile-cli.ts search Demo
sh
node profile-cli.js search Demo
sh
node profile-cli.mjs search Demo
sh
node profile-cli.cjs search Demo

Captured with terminal colours enabled. This fixture has no saved password or private key; those rows are empty.

Found 1 profile

┌──────────────────┬────────────┐
│ Label            │ Value      │
├──────────────────┼────────────┤
│ Name             │ Demo       │
│ Path             │ Demo       │
│ Protocol         │ ssh        │
│ Host             │ 127.0.0.1  │
│ Port             │ 22         │
│ Username         │ fixture    │
│ Password         │            │
│ Passphrase       │            │
│ Credential state │ not-stored │
│ Authentication   │            │
│ Private key      │            │
│ Remote           │            │
└──────────────────┴────────────┘

Exit codes and stream contracts ​

Successful commands and help return 0. Parsing, source loading and command errors return 1. run returns that code instead of exiting; the quick start assigns it to process.exitCode.

JSON records go to standard output; handled failures go to standard error. An unknown command also prints help on standard output, so callers should use the exit code before treating output as successful JSON. Ordinary handled query failures use {"error":"message"} in JSON mode. Registry write failures can add native code, operation, recovery and backup fields.

Native terminal colours and password states depend on adapter hooks. When hidden credentials are reported in human search output, the engine uses (hidden*) and a footer with the --show-password flag highlighted green. JSON has no ANSI colour codes and does not include that footer. See an adapter's CLI guide for its captured native output.