Skip to content

feat(cli): --json for auth login, logout and whoami - #77

Merged
darwin67 merged 2 commits into
mainfrom
feat/cli-auth-json
Oct 11, 2026
Merged

darwin67 merged 2 commits into
mainfrom
feat/cli-auth-json

Conversation

@darwin67

Copy link
Copy Markdown
Member

Summary

This finishes the CLI half of RFD 3's machine-readable output item. #72 covered the paste commands; this adds --json to the three auth commands. Every CLI command now takes --json and prints one line of JSON on stdout.

Command JSON
auth whoami --json {server, user: {id, email}, token: {id, name, inserted_at}}
auth login --json {status, profile, server, user, token}. status is logged_in, already_logged_in or environment (authenticated through TEXTBIN_TOKEN).
auth logout --json {profile, server, revoked, logged_out}. profile is null when only TEXTBIN_TOKEN was revoked. server is set only when a token was revoked.
  • The API token secret is never printed. token is the metadata the server returns: id, name and creation time. A test checks the secret isn't in the output.
  • The email prompt now goes to stderr, like the password prompt, so stdout carries only the result. Human output is otherwise unchanged.

Commits

  1. refactor: moves print_json to the crate root so the auth commands can use it, and makes the client's identity types serializable.
  2. feat: adds the three --json flags, with tests.

Test plan

  • cargo fmt --check and cargo clippy --workspace --all-features -- -D warnings pass.
  • cargo test --workspace: 63 tests, 0 failures. New tests:
    • The login JSON shape, including that the secret isn't present.
    • Argument parsing for --json on all three auth commands.
  • The refactor commit builds and passes on its own.

🤖 Generated with Claude Code

https://claude.ai/code/session_019fnjMN7WpEjQJD2zveakV6


Generated by Claude Code

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
@github-actions github-actions Bot added the feat label Oct 11, 2026
@darwin67

darwin67 commented Oct 11, 2026 •

Copy link
Copy Markdown
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.

@darwin67
darwin67 marked this pull request as ready for review October 11, 2026 14:02
@darwin67
darwin67 merged commit c20dc18 into main Oct 11, 2026
17 checks passed
@darwin67
darwin67 deleted the feat/cli-auth-json branch October 11, 2026 14:02
@chaba2-bot chaba2-bot Bot mentioned this pull request Oct 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants