Skip to content

feat(profile): add multi-profile configuration system#12

Merged
azconger merged 2 commits intomainfrom
feature/configurable-backend
Jan 24, 2026
Merged

feat(profile): add multi-profile configuration system#12
azconger merged 2 commits intomainfrom
feature/configurable-backend

Conversation

@azconger
Copy link
Copy Markdown
Contributor

Summary

  • Add profile-based configuration allowing users to switch between different StackHawk organizations, user accounts, or API keys
  • Introduce GlobalOptions struct to consolidate CLI parameters, simplifying command handler signatures
  • Add profile management commands: list, use, create, delete, show
  • Implement backward-compatible migration from v1 to v2 config format

Changes

New files:

  • src/cli/args/global.rs - GlobalOptions struct consolidating all global CLI options
  • src/cli/profile.rs - Profile command handlers

Key modifications:

  • src/config/mod.rs - New ProfileConfig and ProfiledConfig types with v1→v2 migration
  • src/cli/context.rs - Accept &GlobalOptions instead of 6 parameters
  • src/main.rs - Simplified routing using GlobalOptions
  • All command handlers updated to use &GlobalOptions

Config Format (v2)

version: 2
active_profile: default

profiles:
  default:
    api_key: hawk.xxx...
    org_id: org_123
    jwt:
      token: "..."
      expires_at: "2024-..."

Test plan

  • cargo test - All 206 unit tests pass
  • cargo clippy -- -D warnings - No warnings
  • Manual testing of profile commands
  • Verify v1 config migration works

🤖 Generated with Claude Code

azconger and others added 2 commits January 24, 2026 11:35
Introduce profile-based configuration allowing users to manage multiple
StackHawk configurations with named profiles. Each profile stores its own
API key, organization, and cached JWT token.

New features:
- Profile commands: list, use, create, delete, show
- --profile/-P global flag for one-time profile override
- HAWKOP_PROFILE environment variable support
- Automatic v1 to v2 config migration (backward compatible)

Architecture improvements:
- Introduce GlobalOptions struct to consolidate CLI parameters
- Simplify all command handler signatures
- Update CommandContext to accept single &GlobalOptions parameter

Config format v2 example:
  version: 2
  active_profile: prod
  profiles:
    prod:
      api_key: sk_prod_...
      org_id: org_123
    test:
      api_key: sk_test_...
      org_id: org_456

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Remove implications that profiles target different API hosts. Profile
help now emphasizes switching between organizations, user accounts,
and API keys rather than environments like prod/test/local.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@azconger azconger merged commit 1af3eba into main Jan 24, 2026
5 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.

1 participant