Skip to content

feat: add --output json global flag for machine-readable output#34

Merged
aaearon merged 1 commit intomainfrom
feat/output-json
Feb 21, 2026
Merged

feat: add --output json global flag for machine-readable output#34
aaearon merged 1 commit intomainfrom
feat/output-json

Conversation

@aaearon
Copy link
Owner

@aaearon aaearon commented Feb 21, 2026

Summary

  • Adds --output/-o persistent flag on root command accepting text (default) or json
  • JSON mode forces non-interactive by setting IsTerminalFunc to return false
  • All commands now support JSON output: root elevation, env, status, revoke, favorites list
  • Creates cmd/output.go (helpers), cmd/output_types.go (JSON structs)
  • Adds json:"..." struct tags to config.Favorite alongside existing yaml:"..." tags

Test plan

  • TestIsJSONOutput / TestWriteJSON / TestOutputFlagValidation
  • TestRootElevate_JSONOutput — Azure, AWS with credentials, group elevation
  • TestEnvCommand_JSONOutput / TestStatusCommand_JSONOutput / TestRevokeCommand_JSONOutput / TestFavoritesList_JSONOutput
  • All existing tests pass, lint clean

Add persistent --output/-o flag (text/json) validated in PersistentPreRunE.
JSON mode forces non-interactive by setting IsTerminalFunc to false.

All commands now support JSON output:
- Root elevation: cloudElevationOutput / groupElevationJSON
- grant env: awsCredentialOutput
- grant status: statusOutput with sessions array
- grant revoke: []revocationOutput
- grant favorites list: []favoriteOutput

Add json struct tags to config.Favorite alongside yaml tags.
@aaearon aaearon merged commit fa143d6 into main Feb 21, 2026
1 check passed
@aaearon aaearon deleted the feat/output-json branch February 21, 2026 08:32
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