Skip to content

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

@rianjs

Description

@rianjs

Summary

Add an init command for guided setup, config test for connectivity verification, and config clear to remove all stored credentials.

Current State

  • Has: config show, config set-api-key, config set-account-id, config set-region, config delete-api-key, config delete-account-id, config fix-permissions
  • Missing: guided init wizard, config test, config clear (clear all at once)

Commands to Add

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 query "SELECT count(*) FROM Transaction"

Features:

  • Interactive prompts for API key, account ID, region
  • Connectivity verification (unless --no-verify)
  • Existing config detection with overwrite prompt
  • Secure storage (Keychain on macOS, config file on Linux)
  • Optional: --api-key, --account-id, --region flags for non-interactive use

2. newrelic-cli config test

Explicit connectivity test:

$ newrelic-cli config test
Testing connection to New Relic (US region)...
✓ API key valid
✓ Account 12345 accessible
✓ NerdGraph API responding

Account: My Account (12345)
Region: US

On failure:

$ newrelic-cli config test
Testing connection to New Relic (US region)...
✗ API key invalid or expired

Check your credentials with: newrelic-cli config show
Reconfigure with: newrelic-cli init

3. newrelic-cli config clear

Remove all stored credentials at once:

$ newrelic-cli config clear
Cleared API key from keychain
Cleared account ID
Cleared region setting

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

This is simpler than running config delete-api-key + config delete-account-id separately.

Implementation Notes

  • Can use NerdGraph introspection query or simple account query to verify connectivity
  • init should call the same verification logic as config test
  • Consider charmbracelet/huh for TUI prompts or simple stdin prompts

Related

  • Matches patterns in confluence-cli (init), slack-chat-api (config test), jira-ticket-cli (config clear)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions