Repository navigation
feat(cli): --json for auth login, logout and whoami - #77
Merged
Merged
Conversation
Move print_json from the paste commands' module to the crate root so the auth commands can use it too, and derive Serialize on the client's Identity, AuthenticatedUser and ApiTokenMetadata. ApiTokenMetadata holds only the token's id, name and creation time, never the secret. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019fnjMN7WpEjQJD2zveakV6
Finish RFD 3's machine-readable output item: every CLI command now takes
--json and prints one line of JSON on stdout.
- whoami: {server, user, token}
- login: {status, profile, server, user, token}, where status is
logged_in, already_logged_in or environment (TEXTBIN_TOKEN). The API
token secret is never printed.
- logout: {profile, server, revoked, logged_out}. profile is null when
only TEXTBIN_TOKEN was revoked; server is set only when a token was
revoked.
The email prompt now goes to stderr, like the password prompt, so stdout
carries only the result. Human output is unchanged apart from that.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019fnjMN7WpEjQJD2zveakV6
Member
Author
|
Oracle review complete: signed off, no blockers. Reviewed auth JSON output, secret-free metadata serialization, stderr/terminal prompting, and propagation of authentication/storage/revocation errors before success output. No code correction was required. Validation: cargo fmt --check, cargo clippy --workspace --all-features -- -D warnings, and cargo test --workspace passed (63 tests). Review session: https://ampcode.com/threads/T-01a12594-e2f1-75be-b343-9239564f5c84 CI is green at the reviewed head. For PR78 this includes the fresh post-fix memory/local/S3 test matrix, Rust tests, formatting/linting, and production-container build; release/publication jobs skipped as expected. |
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
This finishes the CLI half of RFD 3's machine-readable output item. #72 covered the paste commands; this adds
--jsonto the threeauthcommands. Every CLI command now takes--jsonand prints one line of JSON on stdout.auth whoami --json{server, user: {id, email}, token: {id, name, inserted_at}}auth login --json{status, profile, server, user, token}.statusislogged_in,already_logged_inorenvironment(authenticated throughTEXTBIN_TOKEN).auth logout --json{profile, server, revoked, logged_out}.profileisnullwhen onlyTEXTBIN_TOKENwas revoked.serveris set only when a token was revoked.tokenis the metadata the server returns: id, name and creation time. A test checks the secret isn't in the output.Commits
refactor: movesprint_jsonto the crate root so the auth commands can use it, and makes the client's identity types serializable.feat: adds the three--jsonflags, with tests.Test plan
cargo fmt --checkandcargo clippy --workspace --all-features -- -D warningspass.cargo test --workspace: 63 tests, 0 failures. New tests:loginJSON shape, including that the secret isn't present.--jsonon all three auth commands.🤖 Generated with Claude Code
https://claude.ai/code/session_019fnjMN7WpEjQJD2zveakV6
Generated by Claude Code