Conversation
Replace single-space auth config with current_space + spaces list. Add current_space_key() helper that resolves BL_SPACE env var first, then falls back to current_space in config. Migrate old [auth] format automatically on load.
- auth list: show all configured spaces with * on current - auth use <key>: switch the current space - auth logout: now takes optional space_key arg (defaults to current) - auth logout --all: remove all spaces from keyring and delete config files
--space <SPACE_KEY> overrides the active space for a single command. Internally sets BL_SPACE env var, which current_space_key() checks first. Users can also export BL_SPACE directly for the same effect.
Document auth list, auth use, per-command --space flag, BL_SPACE env var, logout with space key arg, logout --all, and new config file format.
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughThis PR introduces multi-space authentication: config now tracks multiple spaces and a current space, CLI gains commands to list/use/logout per-space (and logout --all), login updates spaces/current, legacy configs are migrated on load, and client/auth flows resolve the active space via env or config. Changes
Sequence Diagram(s)sequenceDiagram
participant CLI as CLI (user)
participant Config as Config
participant Secret as Credentials Store
participant API as Backlog API
CLI->>Config: resolve current space (BL_SPACE or current_space_key())
Config-->>CLI: return space_key
CLI->>Secret: read/write credentials for space_key
Secret-->>CLI: return API key / confirm deletion
CLI->>API: initialize BacklogClient with API key and space in base_url
API-->>CLI: respond to auth request (login/status)
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
✨ Simplify code
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/main.rs (1)
531-537: Consider adding mutual exclusivity betweenspace_keyand--all.When both
space_keyand--allare provided, the current logic silently ignoresspace_keyand runslogout_all(). This could confuse users who expect an error for conflicting arguments.Option: Use clap's conflicts_with attribute
/// Logout and remove stored credentials Logout { /// Space key to logout from (defaults to current space) + #[arg(conflicts_with = "all")] space_key: Option<String>, /// Logout from all spaces and remove all config files #[arg(long)] all: bool, },🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/main.rs` around lines 531 - 537, The Logout variant currently accepts both space_key (Option<String>) and the flag all (bool) which can conflict; update the clap configuration on the Logout variant to make these mutually exclusive so the CLI returns an error when both are provided (e.g., use clap's conflicts_with or similar on the all field or on space_key) so the code path that calls logout_all() cannot silently ignore space_key; reference the Logout enum and its fields space_key and all when making the change.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/main.rs`:
- Around line 531-537: The Logout variant currently accepts both space_key
(Option<String>) and the flag all (bool) which can conflict; update the clap
configuration on the Logout variant to make these mutually exclusive so the CLI
returns an error when both are provided (e.g., use clap's conflicts_with or
similar on the all field or on space_key) so the code path that calls
logout_all() cannot silently ignore space_key; reference the Logout enum and its
fields space_key and all when making the change.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 2ae3d997-6183-4e40-ac23-bfd431cb59ef
📒 Files selected for processing (5)
docs/user-guide.mdsrc/api/mod.rssrc/cmd/auth.rssrc/config.rssrc/main.rs
There was a problem hiding this comment.
Pull request overview
Adds multi-space support to the Backlog CLI by introducing a new config shape (current_space + spaces[]), space selection via BL_SPACE / --space, and new bl auth subcommands for managing multiple spaces.
Changes:
- Refactor config loading to support multiple spaces and migrate legacy
[auth] space_keyon load. - Extend
bl authwithlist,use, and enhancedlogout(per-space or--all), plus a global--spaceoverride. - Update API client initialization and user guide docs to reflect multi-space behavior.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| src/main.rs | Adds global --space flag and wires new auth subcommands/flags into CLI dispatch. |
| src/config.rs | Replaces single-space auth metadata with current_space + spaces, adds current_space_key() and legacy migration logic + tests. |
| src/cmd/auth.rs | Updates login/status to use the new config model and adds multi-space management commands (list, use, enhanced logout). |
| src/api/mod.rs | Updates BacklogClient::from_config() to resolve the effective space via current_space_key(). |
| docs/user-guide.md | Documents multi-space workflows, updated logout semantics, and updated config format. |
Addresses review comment: "bl auth logout <space_key> --all is currently accepted and the positional space_key is silently ignored"
Addresses review comment: "use_space() allocates a new String just to check membership"
…ssage for missing space Addresses review comment: "status() treats any error from config::current_space_key() as 'not logged in'"
Addresses review comment: "logout_all() hardcodes the
~/.config/bl/{config.toml,credentials.toml} layout inline"
Extract remove_space_from_config() helper and test all removal cases: current removed, non-current removed, last space removed. Addresses review comment: "Multi-space behaviors were added, but this module's tests currently cover only status_with/JSON building"
Checklist
mainSummary
blinstallation[auth] space_keyconfig format is migrated automatically on first runReason for change
Users who belong to multiple Backlog spaces had to reconfigure credentials every time they switched spaces.
Changes
refactor(config): Replace single-spaceConfigwithcurrent_space+spaces[]. Addcurrent_space_key()helper that resolvesBL_SPACEenv var first, then falls back tocurrent_space. Migrate old[auth]format transparently on load.feat(auth): Addauth list,auth use <key>,auth logout [key],auth logout --allfeat: Add--space <SPACE_KEY>global flag for per-command space overridedocs: Update user-guide with multi-space usage and uninstall instructionsNotes
LegacyAuthConfigandmigrate()can be removed in a future version once the old config format is no longer in use.