Commit cca24e1
Adopt profile package for multi-account auth (#78)
* Add profile-based multi-account auth with basecamp/cli profile package
Replace custom Config.Accounts/AddAccount/RemoveAccount with profile.Store
backed by ~/.config/fizzy/config.json. Credential keys change from
"token:<account>" to "profile:<name>" via credstore.
Key changes in root.go:
- Add profile.Store initialization and --profile global flag
- resolveProfile() uses profile.Resolve() 6-step chain
- Profile settings (layer 3) outrank local/global YAML config (4-5)
but yield to env vars (layer 2) and flags (layer 1)
- Credential helpers: credsSaveProfileToken, credsLoadProfileToken,
credsDeleteProfileToken with legacy key migration
- ensureProfile() does delete-then-create for upsert semantics
Config precedence: flags > env vars > profiles > local config > global > defaults
* Rewrite auth commands for profile-based credential storage
All auth subcommands now operate on profiles instead of accounts:
- auth login: saves to "profile:<name>" credstore key, creates profile
- auth logout: deletes profile and "profile:<name>" key
- auth logout --all: cleans all three legacy key formats
("profile:<name>", "token:<account>", bare "token")
- auth list: reads from profile.Store.List()
- auth switch: calls profiles.SetDefault(), updates YAML config
- auth status: shows profile key in output
Tests rewritten with profile.Store injection via SetTestProfiles().
Covers: invalid --profile flag errors, env var precedence over profile
settings, ensureProfile upsert, logout --all legacy key cleanup.
* Wire setup and signup to profile store
setup: create profile via ensureProfile() + profiles.SetDefault()
signup: saveSignupConfig() creates profile instead of AddAccount()
Both use credsSaveProfileToken for credential storage.
* Update docs and surface for --profile flag and precedence chain
- README/AGENTS: 5-level precedence, --profile flag, FIZZY_ACCOUNT deprecation
- SKILL.md: --account → --profile, precedence includes profile layer
- SURFACE.txt: regenerated with --profile replacing --account globally
* Add integration test for full precedence chain
TestPrecedenceChainIntegration wires up real config files, credstore,
and profile store, then runs config.Load() → resolveProfile() →
resolveToken() → flag override — the same sequence as PersistentPreRunE.
Three cases lock the contract:
- profile outranks YAML config for APIURL and board
- env vars beat profile for all fields
- --api-url flag beats env and profile
* Fix board JSON escaping and auth switch legacy token fallback
- ensureProfile: use json.Marshal for board value instead of manual quoting
- auth switch: fall back to credsLoadLegacyToken when profile key missing
* Update SKILL.md terminology: account → profile throughout
Replace remaining "account" references in auth command examples
and troubleshooting sections with "profile" terminology.
---------
Co-authored-by: Jeremy Daer <jeremy@37signals.com>1 parent e4e3629 commit cca24e1
11 files changed
Lines changed: 1728 additions & 359 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
54 | 57 | | |
55 | 58 | | |
56 | 59 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
120 | 120 | | |
121 | 121 | | |
122 | 122 | | |
123 | | - | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
124 | 126 | | |
125 | 127 | | |
126 | 128 | | |
127 | 129 | | |
128 | 130 | | |
129 | | - | |
130 | | - | |
131 | | - | |
132 | | - | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
133 | 138 | | |
134 | 139 | | |
135 | 140 | | |
| |||
0 commit comments