feat: Add command to show existing profiles in the CLI#4440
Merged
Conversation
Contributor
There was a problem hiding this comment.
Hey - I've found 1 issue, and left some high level feedback:
- In
executeAuthProfiles, the active profile marker is based onconfig.activeProfilewhile ordering ingetOrderedProfileNamesfalls back toDEFAULT_PROFILE, which can lead to no profile being marked active whenactiveProfileis unset; consider using the same fallback logic for both ordering and marker calculation. executeAuthProfileswrites directly toconsole.loginstead 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>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Signed-off-by: Adriano Lazzaretti <lazzaretti136@gmail.com>
Signed-off-by: Adriano Lazzaretti <lazzaretti136@gmail.com>
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.
No description provided.