Skip to content

feat: Add command to show existing profiles in the CLI#4440

Merged
Rockyy174 merged 2 commits into
operately:mainfrom
Rockyy174:show-cli-profiles
May 8, 2026
Merged

feat: Add command to show existing profiles in the CLI#4440
Rockyy174 merged 2 commits into
operately:mainfrom
Rockyy174:show-cli-profiles

Conversation

@Rockyy174
Copy link
Copy Markdown
Collaborator

No description provided.

Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

Hey - I've found 1 issue, and left some high level feedback:

  • In executeAuthProfiles, the active profile marker is based on config.activeProfile while ordering in getOrderedProfileNames falls back to DEFAULT_PROFILE, which can lead to no profile being marked active when activeProfile is unset; consider using the same fallback logic for both ordering and marker calculation.
  • executeAuthProfiles writes directly to console.log instead of using the existing output abstractions (e.g., printInfo/dependency injection as in other auth flows); aligning this with the existing pattern would make output behavior more consistent and easier to test or redirect.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `executeAuthProfiles`, the active profile marker is based on `config.activeProfile` while ordering in `getOrderedProfileNames` falls back to `DEFAULT_PROFILE`, which can lead to no profile being marked active when `activeProfile` is unset; consider using the same fallback logic for both ordering and marker calculation.
- `executeAuthProfiles` writes directly to `console.log` instead of using the existing output abstractions (e.g., `printInfo`/dependency injection as in other auth flows); aligning this with the existing pattern would make output behavior more consistent and easier to test or redirect.

## Individual Comments

### Comment 1
<location path="cli/src/auth/profiles.ts" line_range="16-17" />
<code_context>
+  console.log("Saved CLI profiles:");
+
+  for (const profileName of profileNames) {
+    const profile = config.profiles[profileName] ?? {};
+    const isActive = profileName === config.activeProfile;
+    const marker = isActive ? "*" : "-";
+    const label = isActive ? `${profileName} (active)` : profileName;
</code_context>
<issue_to_address>
**issue:** Align active-profile detection here with the trimming logic used in `getOrderedProfileNames`.

`getOrderedProfileNames` normalizes the active profile with `config.activeProfile?.trim() || DEFAULT_PROFILE`, but here you compare `profileName === config.activeProfile` directly. If `config.activeProfile` has surrounding whitespace, the ordering will treat the trimmed name as active while this loop never does. Normalize once (e.g. `const activeProfile = config.activeProfile?.trim() || DEFAULT_PROFILE;`) and reuse it here when computing `isActive`.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread cli/src/auth/profiles.ts Outdated
Signed-off-by: Adriano Lazzaretti <lazzaretti136@gmail.com>
@Rockyy174 Rockyy174 merged commit 9ebbc66 into operately:main May 8, 2026
3 checks passed
@Rockyy174 Rockyy174 deleted the show-cli-profiles branch May 8, 2026 17:29
Signed-off-by: Adriano Lazzaretti <lazzaretti136@gmail.com>
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