Conversation
Add `zenodo config profiles` to list all configured profiles (marking the default with *) and `zenodo config use <profile>` to switch the default profile. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Adds new zenodo config subcommands to make working with multiple configuration profiles easier (e.g., switching between production and sandbox without manual edits).
Changes:
- Introduces
zenodo config profilesto list configured profiles and mark the default. - Introduces
zenodo config use <profile>to validate and set the default profile. - Registers both commands under the existing
configcommand.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| Long: `List all configured profiles and show which is the default. | ||
|
|
||
| Examples: | ||
| zenodo config profiles`, |
There was a problem hiding this comment.
config profiles currently accepts arbitrary extra args because no Args validator is set. Consider adding Args: cobra.NoArgs so typos like zenodo config profiles foo fail fast with a usage error.
| zenodo config profiles`, | |
| zenodo config profiles`, | |
| Args: cobra.NoArgs, |
| defaultProfile := cfg.DefaultProfile() | ||
| names := cfg.ProfileNames() | ||
|
|
There was a problem hiding this comment.
cfg.ProfileNames() is derived from a map and will iterate in non-deterministic order, which makes zenodo config profiles output unstable across runs. Sort names before printing so output is deterministic (and easier to test/parse).
| // Verify profile exists. | ||
| found := false | ||
| for _, p := range cfg.ProfileNames() { | ||
| if p == name { | ||
| found = true | ||
| break | ||
| } | ||
| } | ||
| if !found { | ||
| return fmt.Errorf("profile %q not found; available profiles: %v", name, cfg.ProfileNames()) | ||
| } |
There was a problem hiding this comment.
This command calls cfg.ProfileNames() multiple times (in the loop and again in the error), and each call may return a different order. Capture the slice once (and ideally sort it) so the existence check and error message are consistent.
| var configProfilesCmd = &cobra.Command{ | ||
| Use: "profiles", | ||
| Short: "List configured profiles", | ||
| Long: `List all configured profiles and show which is the default. | ||
|
|
||
| Examples: | ||
| zenodo config profiles`, |
There was a problem hiding this comment.
The PR description says this closes #21, but Issue #21's acceptance criteria call for zenodo config profiles list / zenodo config profiles use <name> and output that respects --output json|table|csv. The implementation adds zenodo config profiles and zenodo config use <profile> with plain-text output; please confirm the intended CLI contract and update the issue/PR (or adjust the commands/output) so the closure is accurate.
Closes #21
ELI5
Imagine you have two Zenodo accounts — one for real uploads and one for testing (sandbox). Before this change, switching between them meant manually changing settings each time. Now you can just type
zenodo config profilesto see all your saved profiles (with a star next to the active one), andzenodo config use sandboxto instantly switch. Like switching between saved Wi-Fi networks on your phone.Summary
zenodo config profilescommand that lists all configured profiles, marking the default with*zenodo config use <profile>command that switches the default profile (with validation that the profile exists)configChanges
internal/cli/config.go: AddedconfigProfilesCmdandconfigUseCmdcobra commands, registered ininit()Test plan
go build ./...compiles successfullygo test ./...— all 75 tests passzenodo config profilesshows profiles with default marker🤖 Generated with Claude Code