Skip to content

[FEATURE] - Add profile switcher for multi-environment management #22

@dawidpereira

Description

@dawidpereira

Add profile switcher for multi-environment management

Summary

Implement a profile system allowing users to quickly switch between different Azure Service Bus environments (dev/test/prod) or projects using Ctrl+P hotkey.

Why

Users managing multiple environments need to:

  • Switch between dev/test/prod Service Bus namespaces quickly
  • Maintain separate configurations for different projects
  • Avoid manually editing config files when changing contexts
  • Keep credentials separate and secure per environment

Implementation

  • Add profile management system with configuration hierarchy:

    # Embedded in binary (defaults)
    config.toml                     # Default configuration
    keys.toml                       # Default key bindings
    
    # User configuration directory
    ~/.config/quetty/
    ├── config.toml                 # Override embedded defaults (optional)
    ├── keys.toml                   # Override embedded defaults (optional)
    └── profiles/
        ├── dev/
        │   ├── config.toml         # Override for dev profile
        │   ├── keys.toml           # Override keys for dev profile
        │   └── .env                # Secret data (ignored by git)
        ├── test/
        │   ├── config.toml
        │   └── .env
        └── prod/
            ├── config.toml
            └── .env
    
  • Configuration loading hierarchy (each level overrides previous):

    1. Embedded defaults (from binary)
    2. User ~/.config/quetty/config.toml (if exists)
    3. User ~/.config/quetty/keys.toml (if exists)
    4. Profile-specific config.toml
    5. Profile-specific keys.toml
    6. Profile-specific .env
  • Add profile switcher UI:

    • Ctrl+P opens profile selector popup
    • Shows list of available profiles
    • Displays current profile in status bar
    • Returns to start screen after switching
  • Profile management commands:

    quetty --profile dev              # Start with specific profile
    quetty --create-profile staging   # Create new profile
    quetty --list-profiles            # List available profiles

Success Criteria

  • Can switch profiles instantly with Ctrl+P
  • Each profile maintains separate Azure connections
  • Secrets stay in .env files (never in config.toml)
  • Configuration inheritance works correctly
  • Current profile visible in UI

Technical Notes

// Embedded in binary
const DEFAULT_CONFIG: &str = include_str!("../config.toml");
const DEFAULT_KEYS: &str = include_str!("../keys.toml");
# Example embedded config.toml (in binary)
[ui]
theme = "catppuccin"
refresh_interval = 5

[azure]
# No secrets here, just structure

# Example ~/.config/quetty/config.toml (user override)
[ui]
theme = "nightfox"  # User prefers different theme

# Example profiles/dev/config.toml
[azure]
subscription_id = "dev-subscription-id"
resource_group = "dev-rg"
namespace = "dev-servicebus"

# Example profiles/dev/.env
AZURE_CLIENT_ID=xxx
AZURE_CLIENT_SECRET=yyy
AZURE_TENANT_ID=zzz

Profile struct:

struct Profile {
    name: String,
    config: Config,
    is_active: bool,
}

struct ProfileManager {
    profiles: Vec<Profile>,
    current: Option<String>,
}

Related

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions