Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 12, 2025

Enables simultaneous management of multiple Redmine servers. Users can now login to different instances and switch between them using --rid <instance-id> without repeated authentication.

Changes

Configuration

  • Extended config structure to store multiple instances in a map keyed by instance ID
  • Added MultiInstanceConfig_t with instance map and default instance tracking
  • Maintains backward compatibility: legacy single-instance configs load automatically without migration

CLI

  • Added global --rid persistent flag to all commands
  • Flag parsing in PersistentPreRunE before command execution
  • Instance selection: commands without --rid use default, with --rid target specified instance

Authentication

  • auth login --rid <id>: stores credentials for specific instance
  • auth logout --rid <id>: removes only specified instance credentials
  • First login becomes default instance automatically

Testing

  • 7 new unit tests for multi-instance config operations
  • 1 new test for login with --rid flag
  • All existing tests pass (backward compatibility verified)

Usage

# Login to multiple instances
red-cli auth login --rid prod
red-cli auth login --rid staging

# Target specific instance
red-cli issue list --rid staging
red-cli issue create --project 42 --rid prod

# Logout specific instance
red-cli auth logout --rid staging

Config Format

{
  "instances": {
    "prod": {
      "server": "https://prod.redmine.example.com",
      "api-key": "...",
      "user-id": 1,
      "project-id": 23
    },
    "staging": {
      "server": "https://staging.redmine.example.com",
      "api-key": "...",
      "user-id": 5,
      "project-id": 42
    }
  },
  "default-instance": "prod"
}

Documentation

  • Created comprehensive multi-instance guide with examples and use cases
  • Updated README, config guide, and auth command documentation
  • Added examples for common workflows (multiple clients, prod/staging environments)
Original prompt

The feature request is to enable the redmine-cli to support multiple Redmine instances. This includes adding the functionality to login to multiple Redmine instances and use them from the command line. A Redmine instance should be identified by a Redmine ID passed as an argument, such as --rid 2.

To implement this:

  • Update the login functionality to allow managing credentials for multiple instances.
  • Adjust the command-line parsing to recognize and handle the --rid argument.
  • Add support for selecting the desired Redmine instance based on Redmine ID.
  • Ensure backward compatibility, so current single-instance usage still works seamlessly.
  • Write tests to validate the functionality of multi-instance support.
  • Update documentation to explain how to configure and use multiple Redmine instances, including examples of command usage.

This feature should align with milestone v0.2.0.

This pull request was created as a result of the following prompt from Copilot chat.

The feature request is to enable the redmine-cli to support multiple Redmine instances. This includes adding the functionality to login to multiple Redmine instances and use them from the command line. A Redmine instance should be identified by a Redmine ID passed as an argument, such as --rid 2.

To implement this:

  • Update the login functionality to allow managing credentials for multiple instances.
  • Adjust the command-line parsing to recognize and handle the --rid argument.
  • Add support for selecting the desired Redmine instance based on Redmine ID.
  • Ensure backward compatibility, so current single-instance usage still works seamlessly.
  • Write tests to validate the functionality of multi-instance support.
  • Update documentation to explain how to configure and use multiple Redmine instances, including examples of command usage.

This feature should align with milestone v0.2.0.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 4 commits December 12, 2025 22:18
Co-authored-by: MrJeffLarry <369605+MrJeffLarry@users.noreply.github.com>
Co-authored-by: MrJeffLarry <369605+MrJeffLarry@users.noreply.github.com>
Co-authored-by: MrJeffLarry <369605+MrJeffLarry@users.noreply.github.com>
Co-authored-by: MrJeffLarry <369605+MrJeffLarry@users.noreply.github.com>
Copilot AI changed the title [WIP] Add multi-instance support for redmine-cli Add multi-instance support with --rid flag for managing multiple Redmine servers Dec 12, 2025
Copilot AI requested a review from MrJeffLarry December 12, 2025 22:27
- Updated loginApiKey and loginPassword functions to use server name instead of ID.
- Enhanced loginPassword to allow retrying on failed login attempts.
- Modified logout functionality to remove the current server instead of clearing all.
- Refactored CLI command initialization to support multiple server configurations.
- Adjusted issue creation and listing to reference the current server configuration.
- Improved issue viewing to utilize the correct server URL.
- Updated project helper functions to reflect changes in server configuration.
- Revised configuration structure to support multiple servers and improved local/global config handling.
- Added methods for adding, removing, and setting default servers in the configuration.
- Enhanced tests to validate multi-instance setup and configuration integrity.
…ervers

- Implemented `cmdAuthList` to display a list of authenticated Redmine servers.
- Implemented `cmdAuthSwitch` to switch the current authenticated server by name.
- Updated `auth.go` to include new commands in the authentication command group.

fix(config): replace deprecated homedir package with os.UserHomeDir

- Updated `config.go` to use `os.UserHomeDir()` instead of `github.com/mitchellh/go-homedir`.
- Added `GetServers` method to retrieve the list of authenticated servers.

test(config): add unit tests for configuration file operations

- Created `config_fileio_test.go` to test temporary file creation and error handling.
- Enhanced existing tests in `config_test.go` to cover new functionality and edge cases.
…HOME environment variable across different OS
@MrJeffLarry MrJeffLarry marked this pull request as ready for review January 13, 2026 20:55
@MrJeffLarry MrJeffLarry merged commit 071c6b9 into main Jan 13, 2026
3 checks passed
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.

2 participants