Skip to content

feat(cli): add human-friendly text output format (--format text|json)#146

Open
santi698 wants to merge 2 commits into
mainfrom
tssdk-61-restructure-cli-commands
Open

feat(cli): add human-friendly text output format (--format text|json)#146
santi698 wants to merge 2 commits into
mainfrom
tssdk-61-restructure-cli-commands

Conversation

@santi698

Copy link
Copy Markdown
Collaborator

Summary

Adds a --format <text|json> option (default text) to all read/mutation CLI commands, similar to kubectl's -o convention:

  • text (default): human-friendly table (via cli-table3) for list commands, and a concise key/value summary for single-resource get/create commands. Only the most relevant fields are shown.
  • json: full raw response, unchanged from prior behavior — for scripting.

Architecture

  • cli-functions.ts is now format-agnostic: each function fetches data via the SDK and returns it (or undefined after reporting an error and exiting), instead of printing the result itself.
  • utils/formatting.ts adds a format(outputFormat, dataPromise, textPrinter) composer that awaits the data and either prints raw JSON or delegates to a text printer, skipping printing if the data resolved to undefined.
  • cli.ts composes fetching + formatting per command using named top-level printer functions (e.g. printApplicationsTable, printRunDetails) to keep nesting shallow.

Changes

  • packages/cli/src/utils/formatting.ts (new): printJson, printTable, printKeyValue, printResult, format.
  • packages/cli/src/cli-functions.ts: dropped output/formatting responsibility, functions return data.
  • packages/cli/src/cli.ts: composes format() + named printers per command; added global --format option.
  • packages/cli/package.json: added cli-table3 (MIT, well-established table rendering library).
  • Updated packages/cli/README.md with --format usage.
  • Updated unit tests (cli-functions.spec.ts, cli.test.ts) and added utils/formatting.spec.ts.

Testing

  • npm run test --workspace @aignostics/cli — 176 tests passing
  • npm run typecheck — clean
  • npm run lint — clean
  • npm run build — clean

Refs: TSSDK-70

santi698 added 2 commits July 10, 2026 16:01
Replace flat command names with grouped subcommands mirroring the
Platform API resource nouns:

- `applications`: list, get, versions list, versions get
- `runs`: create, list, get, cancel, results list
- `auth`: login, logout, status

`runs create` now accepts items via --items <json>, --items-file
<path>, or piped stdin, replacing the old raw JSON string argument.

BREAKING CHANGE: old flat command names (create-run,
list-application-runs, cancel-run, login, etc.) are removed, not
aliased. Update scripts to use the new grouped syntax, e.g.
`aignostics-platform runs create` instead of
`aignostics-platform create-run`.

Refs: TSSDK-61
Adds a --format option (text [default], json) to all read/mutation
commands. text renders tables/key-value summaries with the most
relevant fields via cli-table3; json prints the full raw response
for scripting, preserving prior behavior.

cli-functions.ts is now format-agnostic: it returns fetched data
instead of printing it. cli.ts composes fetching + formatting via a
new format() helper in utils/formatting.ts, keeping the two concerns
decoupled.

Refs TSSDK-70
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant