Skip to content

Commit

Permalink
Added shutdown spinner & auto-populate code
Browse files Browse the repository at this point in the history
This means that users won't have to copy paste the code, and that when teh user cancels the process, they get an immediate notification as this sometimes takes a couple of seconds to shut down
  • Loading branch information
dylanratcliffe committed Oct 16, 2024
1 parent 5497b5d commit 61a8775
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
5 changes: 5 additions & 0 deletions cmd/explore.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,11 @@ func Explore(cmd *cobra.Command, args []string) error {
return fmt.Errorf("error reading keyboard input: %w", err)
}

// This spinner will spin forever as the command shuts down as this could
// take a couple of seconds and we want the user to know it's doing
// something
_, _ = pterm.DefaultSpinner.WithWriter(multi.NewWriter()).Start("Shutting down")

return nil
}

Expand Down
8 changes: 7 additions & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -488,8 +488,14 @@ func getOauthToken(ctx context.Context, oi sdp.OvermindInstance, requiredScopes
}

var token *oauth2.Token
var urlToOpen string
if deviceCode.VerificationURIComplete != "" {
urlToOpen = deviceCode.VerificationURIComplete
} else {
urlToOpen = deviceCode.VerificationURI
}

_ = browser.OpenURL(deviceCode.VerificationURI) // nolint:errcheck // we don't care if the browser fails to open
_ = browser.OpenURL(urlToOpen) // nolint:errcheck // we don't care if the browser fails to open
pterm.Print(
markdownToString(MAX_TERMINAL_WIDTH, fmt.Sprintf(
beginAuthMessage,
Expand Down

0 comments on commit 61a8775

Please sign in to comment.