Skip to content

feat: add init command, config test, and config clear#60

Merged
piekstra merged 2 commits intomainfrom
piekstra/54-init-config-commands
Jan 23, 2026
Merged

feat: add init command, config test, and config clear#60
piekstra merged 2 commits intomainfrom
piekstra/54-init-config-commands

Conversation

@piekstra
Copy link
Copy Markdown
Collaborator

@piekstra piekstra commented Jan 23, 2026

[#54]

Add init command for guided setup and config management improvements.

New Commands

1. newrelic-cli init - Interactive Setup Wizard

$ newrelic-cli init
New Relic CLI Setup

API Key (NRAK-...): ****
Account ID: 12345
Region (US/EU) [US]: US

Testing connection...
✓ API key valid
✓ Account 12345 accessible

Configuration saved.

Try it out:
  newrelic-cli apps list
  newrelic-cli nrql "SELECT count(*) FROM Transaction"

Features:

  • Interactive prompts for API key, account ID, region
  • Connectivity verification (unless --no-verify)
  • Existing config detection with overwrite warning
  • Non-interactive mode with --api-key, --account-id, --region flags

2. newrelic-cli config test - Connectivity Verification

$ newrelic-cli config test
Testing connection to New Relic...

Region: US

✓ API key valid
  User: user@example.com
✓ Account 12345 accessible
  Name: My Account
✓ NerdGraph API responding

✓ Connection test passed!

3. newrelic-cli config clear - Remove All Credentials

$ newrelic-cli config clear
Clear all stored credentials (API key, account ID, region)? [y/N]: y
✓ Cleared API key from Keychain
✓ Cleared account ID from Keychain
✓ Cleared region setting

Note: Environment variables (NEWRELIC_*) will still be used if set.

Test Plan

  • Build passes: make build
  • Tests pass: make test
  • init --help shows correct usage
  • config test --help shows correct usage
  • config clear --help shows correct usage
  • Interactive init works with prompts
  • Non-interactive init works with flags: init --api-key X --account-id Y --region US --no-verify
  • config test verifies credentials
  • config clear removes all credentials

Closes #54

- Add `init` command for interactive setup wizard with connection verification
- Add `config test` to verify API key and account access
- Add `config clear` to remove all stored credentials at once
- Add `TestConnection()` API method for connectivity verification

Supports both interactive prompts and non-interactive flags for automation.

[#54]
@piekstra piekstra force-pushed the piekstra/54-init-config-commands branch from eebee97 to 5a765a7 Compare January 23, 2026 16:57
@piekstra piekstra merged commit e9c5e5e into main Jan 23, 2026
2 checks passed
@piekstra piekstra deleted the piekstra/54-init-config-commands branch January 23, 2026 18:33
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.

Add init command, config test, and config clear for guided setup

2 participants