Skip to content

feat: add whoami command#657

Merged
apucacao merged 5 commits into
mainfrom
ag/whoami-cmd
May 29, 2026
Merged

feat: add whoami command#657
apucacao merged 5 commits into
mainfrom
ag/whoami-cmd

Conversation

@apucacao
Copy link
Copy Markdown
Contributor

@apucacao apucacao commented Mar 11, 2026

Requirements

  • I have added test coverage for new or changed functionality
  • I have followed the repository's pull request submission guidelines
  • I have validated my changes against all supported platform versions

Related issues

N/A

Describe the solution you've provided

Adds ldcli whoami — shows who your current access token belongs to. Reads from config/env like other commands, so you don't need to pass --access-token explicitly (similar to gh auth status).

$ ldcli whoami
Ariel Flores <ariel@acme.com>
Role:    admin
Token:   my-api-token (personal)
Account: abc123

Describe alternatives you've considered

N/A

Additional context


Note

Low Risk
Read-only API calls using the user's existing token; no auth or persistence changes beyond registering a new CLI command.

Overview
Adds ldcli whoami, a top-level command that reports which LaunchDarkly identity your configured access token represents (similar in spirit to gh auth status).

The command reads LD_ACCESS_TOKEN / config like other commands, and is registered on the root CLI with whoami included in the set that does not require the global --access-token flag at parse time. It calls GET /api/v2/caller-identity; with default plaintext output it best-effort enriches the result via /api/v2/members/{id} and /api/v2/account (member name/email/role, token label/kind including service tokens, organization or account id). --output json returns only the raw caller-identity payload. Help temporarily hides persistent flags that are irrelevant for this subcommand.

Tests cover the happy path, account/org fallback, non-member tokens, missing token error, and JSON output.

Reviewed by Cursor Bugbot for commit fd669a4. Bugbot is set up for automated code reviews on this repo. Configure here.

apucacao and others added 4 commits May 20, 2026 17:06
Adds `ldcli whoami` which calls /api/v2/caller-identity to show
information about the identity associated with the current access token
(token name, auth kind, member ID, scopes, etc.).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Removes --access-token requirement from whoami — the command reads
the token from config/env (like ldcli login sets up), matching the
pattern of gh auth status and similar commands.

Also hides --access-token, --base-uri, and --analytics-opt-out from
whoami's help output since they're not relevant to this command.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Fetches /api/v2/members/{id} after caller-identity when a memberId
is present, giving plaintext output like:

  Ariel Flores <ariel@acme.com>
  Role:    admin
  Token:   my-api-token (personal)

JSON output remains the raw caller-identity response for scripting.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@apucacao apucacao marked this pull request as ready for review May 20, 2026 17:23
@apucacao apucacao requested a review from tarqd May 29, 2026 00:33
Copy link
Copy Markdown
Contributor

@tarqd tarqd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested, looks good to me! One thing that would be great to add is the organization name vs just the account id but enhancement not a blocker

@apucacao apucacao merged commit d2cca65 into main May 29, 2026
8 checks passed
@apucacao apucacao deleted the ag/whoami-cmd branch May 29, 2026 18:19
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.

2 participants