Skip to content

feat: multi-profile auth via --profile flag#127

Merged
flipbit03 merged 7 commits intomainfrom
feat/126-feat-multi-profile-auth-via-profile-flag
Mar 8, 2026
Merged

feat: multi-profile auth via --profile flag#127
flipbit03 merged 7 commits intomainfrom
feat/126-feat-multi-profile-auth-via-profile-flag

Conversation

@flipbit03
Copy link
Owner

@flipbit03 flipbit03 commented Mar 8, 2026

Summary

Closes #126

  • Add --profile <name> global flag to switch between API tokens stored as ~/.linear_api_token_<name> files
  • --profile default maps to ~/.linear_api_token for consistency
  • --profile and --api-token are mutually exclusive (clap hard error)
  • --profile skips the env var — goes straight to the named file
  • Actionable error messages when a profile file is missing (lists available profiles + creation hint)
  • lineark usage shows active profile and other available profiles on line 3

SDK breaking changes:

  • Remove Client::auto(), Client::from_file(), auth::auto_token(), auth::token_file_path()
  • Add Client::from_token_file(&Path), change auth::token_from_file() to accept &Path
  • SDK is now path-agnostic — the ~/.linear_api_token convention lives in the CLI only

Test-utils: Refactored test_token() to use lineark_sdk::auth::token_from_file() instead of duplicating file-reading logic.

Test plan

  • make check passes (fmt, clippy, doc, build)
  • make test passes (218 tests, 15 new profile-specific offline tests)
  • make test-online with ~/.linear_api_token_test
  • Manual: lineark --profile work whoami with a valid ~/.linear_api_token_work
  • Manual: lineark --profile nonexistent whoami shows available profiles + creation hint
  • Manual: lineark usage shows active profile + available profiles
  • Manual: lineark --profile work usage reflects the work profile on line 3

Add `--profile <name>` global flag to switch between multiple API tokens
stored as `~/.linear_api_token_<name>` files. Profiles are just named
token files — no config format, no new dependencies.

SDK breaking changes:
- Remove `Client::auto()`, `Client::from_file()`, `auth::auto_token()`
- Add `Client::from_token_file(&Path)`, change `auth::token_from_file()`
  to accept `&Path` — SDK is now path-agnostic, CLI owns conventions

CLI:
- `--profile` conflicts with `--api-token` (clap hard error)
- `--profile default` maps to `~/.linear_api_token`
- `--profile` skips env var — goes straight to the named file
- Actionable error messages when profile file is missing
- `lineark usage` shows active profile and available alternatives

Closes #126
- Extract profile.rs module from inline code in main.rs and usage.rs
- Remove `home` crate from SDK (no longer needed since SDK is path-agnostic)
- Add test helper `lineark_with_profiles()` to reduce test boilerplate
- Add edge-case tests: hyphenated names, dotted names, whitespace-only tokens
- Fix stale SDK API references in MASTERPLAN.md and top-level README
- Fix mutation signatures in SDK README (comment_update, comment_resolve,
  issue_label_create, issue_label_update)
- Document --profile feature in CLI README and top-level README
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.

feat: multi-profile auth via --profile flag

1 participant