feat(cli): add human-friendly text output format (--format text|json)#146
Open
santi698 wants to merge 2 commits into
Open
feat(cli): add human-friendly text output format (--format text|json)#146santi698 wants to merge 2 commits into
santi698 wants to merge 2 commits into
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a
--format <text|json>option (defaulttext) to all read/mutation CLI commands, similar to kubectl's-oconvention:text(default): human-friendly table (viacli-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.tsis now format-agnostic: each function fetches data via the SDK and returns it (orundefinedafter reporting an error and exiting), instead of printing the result itself.utils/formatting.tsadds aformat(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 toundefined.cli.tscomposes 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: composesformat()+ named printers per command; added global--formatoption.packages/cli/package.json: addedcli-table3(MIT, well-established table rendering library).packages/cli/README.mdwith--formatusage.cli-functions.spec.ts,cli.test.ts) and addedutils/formatting.spec.ts.Testing
npm run test --workspace @aignostics/cli— 176 tests passingnpm run typecheck— cleannpm run lint— cleannpm run build— cleanRefs: TSSDK-70