Skip to content

feat: add whoami command#12

Open
fabianmossberg wants to merge 1 commit into
kgajera:mainfrom
fabianmossberg:feat/whoami
Open

feat: add whoami command#12
fabianmossberg wants to merge 1 commit into
kgajera:mainfrom
fabianmossberg:feat/whoami

Conversation

@fabianmossberg

Copy link
Copy Markdown
Contributor

Add a hrvst whoami command that shows the currently authenticated user. It reuses the existing users/me request definition and the shared httpRequest helper, then prints name, email, user id, account id, timezone, and access roles in a table. Pass -o json to print the full user object instead.

Wire it into the command barrel, the generator's command dictionary, the README reference, the docs, and a --help regression test so it matches the existing commands.

Add a `hrvst whoami` command that shows the currently authenticated
user. It reuses the existing users/me request definition and the shared
httpRequest helper, then prints name, email, user id, account id,
timezone, and access roles in a table. Pass `-o json` to print the full
user object instead.

Wire it into the command barrel, the generator's command dictionary,
the README reference, the docs, and a --help regression test so it
matches the existing commands.
@kgajera

kgajera commented Jun 3, 2026

Copy link
Copy Markdown
Owner

@claude Review this PR

@claude

claude Bot commented Jun 3, 2026

Copy link
Copy Markdown

Claude finished @kgajera's task in 2m 1s —— View job


PR Review: feat: add whoami command

  • Read CLAUDE.md and existing codebase for context
  • Read changed files
  • Analyze implementation and provide feedback

Overview

The implementation is clean and integrates well with the existing codebase patterns. It reuses httpRequest, spinner, and verticalTable correctly, follows the same output-handling idiom as generated commands, and is properly wired into the barrel, generator dictionary, README, docs, and tests. A few minor issues worth addressing:


Issues

1. getConfig() called twice per invocation

whoami.ts:35 calls getConfig() to get config.accountId for the table, but httpRequest also calls getConfig() internally (see postman-request-command.ts:131). This doubles the config reads per command invocation.

Since httpRequest doesn't expose config in its return value, consider either calling getConfig() once and passing the result through, or simply making a second call acceptable given it's a cheap local read — but it's worth noting the redundancy.

Fix this →


2. --output option description is misleading

whoami.ts:31:

describe: "The output format: json, table",

The command only has a special case for json; the default (table) is not a named option the user can explicitly pass. Passing -o table silently falls through to the default table output, which works but suggests table is a first-class value when it isn't. Consider changing to:

describe: "The output format (json)",

This matches the actual behavior and avoids implying table is a valid explicit argument.

Fix this →


3. docs/commands/Whoami.md is missing the JSON output example

docs/commands/Whoami.md only shows the basic invocation. The PR description explicitly calls out -o json as a feature. Comparing to the PR body: "Pass -o json to print the full user object instead." — this should appear in the docs.

# Whoami

Display the currently authenticated user:

hrvst whoami


Print the full user object as JSON:

hrvst whoami -o json

Fix this →


Minor Observations (no action needed)

  • src/commands/index.ts is marked "do not modify" but was modified directly rather than regenerated. This is fine because running bun run generate would produce the same result (it scans the src/commands/ directory), so the manual change is equivalent to what generation would produce.
  • User interface is a subset of the API response — this is intentional and correct; TypeScript structural typing means extra API fields are just ignored.
  • Account ID comes from config, not the API response — this is a reasonable design decision since the authenticated account is already known from config.

Summary

Good, idiomatic implementation. The three issues above are minor; the most impactful is the misleading --output description. The core logic, integration wiring, and test coverage are solid.

Comment thread src/commands/whoami.ts
})
.version(false);

export const handler = async (args: WhoamiArguments): Promise<void> => {

@kgajera kgajera Jun 3, 2026

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

From within this handler, do you think we could replace the current implementation with a call to the handler from the me command.

Here's an example where we do that for another command and specifying a subset of fields to output: https://github.com/kgajera/hrvst-cli/blob/main/src/commands/stop-timer.ts#L56

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