Skip to content

Adds login list and login switch commands and ability to maintain multiple logged in profiles#1433

Merged
jar-stripe merged 14 commits intomasterfrom
jar/login-switcher
Mar 20, 2026
Merged

Adds login list and login switch commands and ability to maintain multiple logged in profiles#1433
jar-stripe merged 14 commits intomasterfrom
jar/login-switcher

Conversation

@jar-stripe
Copy link
Copy Markdown
Contributor

@jar-stripe jar-stripe commented Jan 29, 2026

Reviewers

r? @
cc @stripe/developer-products

Summary

This PR adds the ability to manage multiple logged-in Stripe accounts in the CLI.

Related to #1135.

New commands:

  • stripe login list - Lists all logged-in accounts, indicating which is currently active
  • stripe login switch <account> - Switches to a different logged-in account

How it works:

The CLI stores each logged-in account as a "profile" in the config file. The [default] profile is always the active one. When switching accounts:

  1. Current [default] is backed up using its display name as the key
  2. Target profile is copied to [default]
  3. Old target key is removed to keep config clean

When logging into a new account, the previous account's credentials are automatically preserved as a backup profile.

Key changes:

  • Added CopyProfile, ListProfiles, SwitchProfile methods to Config
  • Added login list and login switch subcommands
  • Fixed several bugs in profile management (nil panic in RemoveProfile, viper key deletion not persisting)
  • Added comprehensive tests for new functionality

Example usage:

# List all logged-in accounts
$ stripe login list
Available profiles:
  * Production Account (active)
    Test Account
    Acme Corp

# Switch to a different account
$ stripe login switch "Test Account"
Switched to profile: Test Account

Tests:

  • TestCopyProfile / TestCopyProfileErrors
  • TestListProfiles / TestListProfilesEmpty
  • TestRemoveProfile
  • TestSwitchProfile

…login --switch to switch between them by name

changes SaveLoginDetails to save the default profile before creating the new one
adds RemoveProfile call to SwitchProfile to remove the backup of the profile when it becomes the default
modifies ListProfile to print the default profile, but only print each profile once
removes local launch profile
@jar-stripe jar-stripe changed the title [WIP] Implements command to have multiple active logins and switch between them Adds login list and login switch commands and ability to maintain multiple logged in profiles Feb 24, 2026
@jar-stripe jar-stripe marked this pull request as ready for review February 24, 2026 19:47
@jar-stripe jar-stripe requested a review from a team as a code owner February 24, 2026 19:47
@jar-stripe jar-stripe merged commit 9de81eb into master Mar 20, 2026
14 checks passed
@jar-stripe jar-stripe deleted the jar/login-switcher branch March 20, 2026 23:36
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