Skip to content

Add JSON output, client overrides, and README#110

Closed
natefikru wants to merge 5 commits intonate/tvc-non-interactivefrom
nate/tvc-machine-readable
Closed

Add JSON output, client overrides, and README#110
natefikru wants to merge 5 commits intonate/tvc-non-interactivefrom
nate/tvc-machine-readable

Conversation

@natefikru
Copy link
Copy Markdown

@natefikru natefikru commented Mar 26, 2026

Summary

Builds on #109 by adding machine-readable output and explicit client overrides to the TVC CLI, while preserving the simplified non-interactive behavior from the base branch.

Current behavior:

  • --json produces structured stdout for commands that now have machine-readable result shapes
  • status and progress output stay on stderr, while command results stay on stdout
  • global client override flags support API-driven usage without relying on the logged-in config:
    • --api-key-file
    • --api-url
    • --org-id
  • tvc login still treats first-time API key approval as a manual step, and the public key/setup instructions are always shown even under --quiet
  • tvc deploy approve keeps the stricter base-branch behavior: --no-input does not imply approval, and explicit --yes is still required
  • README is updated to reflect the current command surface and automation flow

This branch intentionally does not include extra surface area that is not implemented or required:

  • no --operator-key-file
  • no implicit approval in non-interactive mode
  • no TTY-based auto no-input detection

Test Plan

  • cargo fmt -p tvc
  • cargo test -p tvc --test login --test deploy_approve --test global_flags --test json_output
  • JSON output tests validate structure and parseability
  • override flags are visible in help
  • quiet-mode behavior is covered for both machine-readable output and login recovery instructions

Depends on: #109

JSON output + stderr/stdout separation:
- All commands define serializable output structs for --json mode
- Status/progress messages routed to stderr via Output helper
- Data/results to stdout as structured JSON or human-readable text
- Fix double JSON output in deploy approve when posting to API

Client override flags:
- Add --api-key-file, --operator-key-file, --api-url, --org-id globals
- build_client_with_overrides() bypasses login config when all overrides set
- Partial overrides supported (override individual values from config)
- Remove unused build_client() function

README overhaul:
- Complete command reference with flag tables
- Environment variables table
- Config file format documentation
- Automation/CI usage examples with full pipeline script
- Troubleshooting section

Tests (16 -> 23):
- JSON output validation for app init, deploy init, deploy approve
- Valid JSON parsing test
- Quiet mode suppression test
- Client override flags in help output test
@natefikru natefikru force-pushed the nate/tvc-machine-readable branch from a5555c7 to 9b0b890 Compare March 26, 2026 22:09
When --api-key-file is provided to tvc login, the CLI now reads the
file and saves it to the org's api_key.json path instead of generating
a new key. Supports both the dashboard export format (JSON array with
camelCase fields like apiKeyName, curveType) and the CLI internal
format (single JSON object with snake_case fields).
When a new keypair is generated during login, the key has not yet been
registered in the dashboard, so credential verification will fail. Instead
of exiting with a 401 error, save the config and key normally and print
instructions to verify later with tvc login --org <alias>.
@natefikru natefikru marked this pull request as draft March 30, 2026 14:49
@natefikru
Copy link
Copy Markdown
Author

Superseded by PRs #112 and #114

@natefikru natefikru closed this Apr 1, 2026
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