Skip to content

Add multi-profile support for switching between accounts#5

Merged
arnif merged 2 commits into
arnif:mainfrom
axelpaul:feature/multi-profile-support
Apr 10, 2026
Merged

Add multi-profile support for switching between accounts#5
arnif merged 2 commits into
arnif:mainfrom
axelpaul:feature/multi-profile-support

Conversation

@axelpaul

@axelpaul axelpaul commented Apr 9, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds named profile support for users with multiple Krónan accounts (e.g., personal + shared family group)
  • kronan token <token> --name <name> saves tokens as named profiles
  • kronan profiles lists all saved profiles with active indicator
  • kronan profile <name> switches the active profile
  • kronan profile remove <name> removes a profile
  • Backward compatible with the existing ~/.kronan/token file

Motivation

Krónan supports shared customer groups (family/household accounts). Each group has its own access token. This feature lets users store multiple tokens and switch between them without re-entering credentials.

Test plan

  • Save two tokens with different names: kronan token <t1> --name personal and kronan token <t2> --name family
  • Verify kronan profiles shows both with active indicator
  • Verify kronan profile <name> switches and subsequent commands use the new profile
  • Verify kronan profile remove <name> removes correctly
  • Verify backward compat: kronan token <t> (without --name) still works, uses identity name as profile name

Allows users with multiple Krónan accounts (e.g., personal + shared
family group) to store and switch between named profiles.

New commands:
- `kronan token <token> --name <name>` - save a named profile
- `kronan profiles` - list saved profiles
- `kronan profile <name>` - switch active profile
- `kronan profile remove <name>` - remove a profile

Profiles stored in ~/.kronan/profiles.json with backward compat
for the legacy ~/.kronan/token file.

@arnif arnif left a comment

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.

Thanks for this great contribution! The multi-profile support is a really useful feature. I've tested it and overall it works well with full backwards compatibility.

One issue to fix before merge:
There's a duplicate 'profile' case label in src/index.ts that causes a lint error. See inline comment on the specific line.

Once that's fixed, this is ready to merge!

@arnif

arnif commented Apr 9, 2026

Copy link
Copy Markdown
Owner

Inline review note:

File: src/index.ts around line 542

The line:

case "me":
case "profile": {

creates a duplicate case error because case "profile": is already used on line 125 for profile management.

Fix: Change line 542 to just:

case "me": {

(remove the case "profile": alias since "profile" now has its own command)

@axelpaul

axelpaul commented Apr 9, 2026

Copy link
Copy Markdown
Contributor Author

@arnif Issue fixed

@arnif arnif left a comment

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.

Thanks for the quick fix! All checks pass now:

✅ Lint passes
✅ TypeScript typecheck passes
✅ All 13 tests passing
✅ Backwards compatibility maintained - existing token works
✅ New profile commands work correctly
✅ 'me' command works without duplicate case error

This is a great addition to the CLI. Approving for merge!

@arnif arnif merged commit fc1c755 into arnif:main Apr 10, 2026
1 check failed
@arnif

arnif commented Apr 10, 2026

Copy link
Copy Markdown
Owner

Ég lét laga þessa format villu bara :)

Þetta er komið í nýjustu útgáfu. Takk kærlega fyrir þetta framlag!

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