From 61a87753f5bfd127590e44a29b4dedda92bc514c Mon Sep 17 00:00:00 2001 From: Dylan Ratcliffe Date: Wed, 16 Oct 2024 12:00:13 +0100 Subject: [PATCH] Added shutdown spinner & auto-populate code 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 --- cmd/explore.go | 5 +++++ cmd/root.go | 8 +++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/cmd/explore.go b/cmd/explore.go index cf6ce93..14cf325 100644 --- a/cmd/explore.go +++ b/cmd/explore.go @@ -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 } diff --git a/cmd/root.go b/cmd/root.go index caaae35..dff77bb 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -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,