Skip to content

Add config profiles and use commands#46

Merged
ran-codes merged 1 commit intomainfrom
issue-21/config-profiles
Feb 17, 2026
Merged

Add config profiles and use commands#46
ran-codes merged 1 commit intomainfrom
issue-21/config-profiles

Conversation

@ran-codes
Copy link
Copy Markdown
Owner

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 profiles to see all your saved profiles (with a star next to the active one), and zenodo config use sandbox to instantly switch. Like switching between saved Wi-Fi networks on your phone.

Summary

  • Add zenodo config profiles command that lists all configured profiles, marking the default with *
  • Add zenodo config use <profile> command that switches the default profile (with validation that the profile exists)
  • Both commands are registered as subcommands of config

Changes

  • internal/cli/config.go: Added configProfilesCmd and configUseCmd cobra commands, registered in init()

Test plan

  • go build ./... compiles successfully
  • go test ./... — all 75 tests pass
  • Manual verification: zenodo config profiles shows profiles with default marker

🤖 Generated with Claude Code

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>
Copilot AI review requested due to automatic review settings February 17, 2026 20:06
@ran-codes ran-codes merged commit 4553ecc into main Feb 17, 2026
3 checks passed
@ran-codes ran-codes deleted the issue-21/config-profiles branch February 17, 2026 20:06
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 profiles to 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 config command.

💡 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`,
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
zenodo config profiles`,
zenodo config profiles`,
Args: cobra.NoArgs,

Copilot uses AI. Check for mistakes.
Comment on lines +115 to +117
defaultProfile := cfg.DefaultProfile()
names := cfg.ProfileNames()

Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Copilot uses AI. Check for mistakes.
Comment on lines +152 to +162
// 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())
}
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment on lines +102 to +108
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`,
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
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.

Config profiles command for listing and switching profiles

2 participants