Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor cli command initialisation and error reporting #410

Merged
merged 1 commit into from
Jun 19, 2024

Conversation

DavidS-ovm
Copy link
Contributor

This unifies all commands to use shared setup/login/error reporting facilities and provide usage info when flag validation fails.

Examples for flagErrors:

vscode ➜ /workspace/cli (dev) $ time go run main.go request load --snapshot-uuid foo
Failed to parse UUID 'foo': invalid UUID length: 3

Usage:
  overmind request load [flags]

Flags:
      --app string             The overmind instance to connect to. (default "https://app.overmind.tech")
[...]

vscode ➜ /workspace/cli (dev) $ time go run main.go request load --snapshot foo
unknown flag: --snapshot

Usage:
  overmind request load [flags]

Flags:
      --app string             The overmind instance to connect to. (default "https://app.overmind.tech")
[...]

Example for loggedError:

vscode ➜ /workspace/cli (dev) $ time go run main.go request query --query foo
ERRO Failed to connect to overmind API             error="failed to WebSocket dial: expected handshake response status code 101 but got 200" gateway-url="https://api.df.overmind-demo.com/api/gateway"

This unifies all commands to use shared setup/login/error reporting
facilities and provide usage info when flag validation fails.

Examples for flagErrors:

```
vscode ➜ /workspace/cli (dev) $ time go run main.go request load --snapshot-uuid foo
Failed to parse UUID 'foo': invalid UUID length: 3

Usage:
  overmind request load [flags]

Flags:
      --app string             The overmind instance to connect to. (default "https://app.overmind.tech")
[...]

vscode ➜ /workspace/cli (dev) $ time go run main.go request load --snapshot foo
unknown flag: --snapshot

Usage:
  overmind request load [flags]

Flags:
      --app string             The overmind instance to connect to. (default "https://app.overmind.tech")
[...]
```

Example for loggedError:

```
vscode ➜ /workspace/cli (dev) $ time go run main.go request query --query foo
ERRO Failed to connect to overmind API             error="failed to WebSocket dial: expected handshake response status code 101 but got 200" gateway-url="https://api.df.overmind-demo.com/api/gateway"
```
@DavidS-ovm DavidS-ovm merged commit 2937f26 into main Jun 19, 2024
5 checks passed
@DavidS-ovm DavidS-ovm deleted the init-refactor branch June 19, 2024 08:59
Copy link

sentry-io bot commented Jun 24, 2024

Suspect Issues

This pull request was deployed and Sentry observed the following issues:

  • ‼️ *errors.errorString: processPlanCmd: risks errored github.com/overmindtech/cli/cmd in (*cmdModel).... View Issue

Did you find this useful? React with a 👍 or 👎

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