Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions cmd/auth/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import (
"context"
"fmt"

"github.com/slackapi/slack-cli/internal/config"
"github.com/slackapi/slack-cli/internal/experiment"
"github.com/slackapi/slack-cli/internal/iostreams"
authpkg "github.com/slackapi/slack-cli/internal/pkg/auth"
"github.com/slackapi/slack-cli/internal/shared"
Expand Down Expand Up @@ -109,7 +111,7 @@ func RunLoginCommand(clients *shared.ClientFactory, cmd *cobra.Command) (types.S
return types.SlackAuth{}, err
}
if selectedAuth.Token != "" {
printAuthSuccess(cmd, clients.IO, credentialsPath, selectedAuth.Token)
printAuthSuccess(cmd, clients.Config, clients.IO, credentialsPath, selectedAuth.Token)
printAuthNextSteps(ctx, clients)
}
return selectedAuth, err
Expand All @@ -119,14 +121,14 @@ func RunLoginCommand(clients *shared.ClientFactory, cmd *cobra.Command) (types.S
if err != nil {
return types.SlackAuth{}, err
} else {
printAuthSuccess(cmd, clients.IO, credentialsPath, selectedAuth.Token)
printAuthSuccess(cmd, clients.Config, clients.IO, credentialsPath, selectedAuth.Token)
printAuthNextSteps(ctx, clients)
}

return selectedAuth, nil
}

func printAuthSuccess(cmd *cobra.Command, IO iostreams.IOStreamer, credentialsPath string, token string) {
func printAuthSuccess(cmd *cobra.Command, config *config.Config, IO iostreams.IOStreamer, credentialsPath string, token string) {
ctx := cmd.Context()

var secondaryLog string
Expand All @@ -136,7 +138,13 @@ func printAuthSuccess(cmd *cobra.Command, IO iostreams.IOStreamer, credentialsPa
secondaryLog = fmt.Sprintf("Service token:\n\n %s\n\nMake sure to copy the token now and save it safely.", token)
}

IO.PrintInfo(ctx, false, "\n%s", style.Sectionf(style.TextSection{
// The legacy prompt leaves no blank line before the success message, so
// print one here. The Charm-based prompt already handles spacing.
if !config.WithExperimentOn(experiment.Charm) {
IO.PrintInfo(ctx, false, "")
}

IO.PrintInfo(ctx, false, "%s", style.Sectionf(style.TextSection{
Emoji: "key",
Text: "You've successfully authenticated!",
Secondary: []string{secondaryLog},
Expand Down
5 changes: 5 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"strings"
"syscall"

"github.com/charmbracelet/huh"
"github.com/slackapi/slack-cli/cmd/app"
"github.com/slackapi/slack-cli/cmd/auth"
"github.com/slackapi/slack-cli/cmd/collaborators"
Expand Down Expand Up @@ -144,6 +145,10 @@ func Init(ctx context.Context) (*cobra.Command, *shared.ClientFactory) {
// updateNotification will check for an update in the background and print a message after the command runs
var updateNotification *update.UpdateNotification

// Override huh's default user abort error with a Slack CLI error so that
// cancelled prompts are handled consistently as process interruptions.
huh.ErrUserAborted = slackerror.New(slackerror.ErrProcessInterrupted)
Comment on lines +148 to +150
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗣️ note: We might want to reconsider how we handle interrupted prompts, but for now I find this suitable at capturing these errors to match current behaviors!


clients = shared.NewClientFactory(shared.SetVersion(version.Raw()))
rootCmd := NewRootCommand(clients, updateNotification)

Expand Down
42 changes: 33 additions & 9 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ go 1.26.0
require (
github.com/AlecAivazis/survey/v2 v2.3.7
github.com/briandowns/spinner v1.23.2
github.com/charmbracelet/huh v0.8.0
github.com/cli/safeexec v1.0.1
github.com/google/uuid v1.6.0
github.com/gorilla/websocket v1.5.3
Expand Down Expand Up @@ -34,26 +35,49 @@ require (
github.com/HdrHistogram/hdrhistogram-go v1.1.2 // indirect
github.com/Microsoft/go-winio v0.6.2 // indirect
github.com/ProtonMail/go-crypto v1.3.0 // indirect
github.com/atotto/clipboard v0.1.4 // indirect
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
github.com/catppuccin/go v0.3.0 // indirect
github.com/chainguard-dev/git-urls v1.0.2 // indirect
github.com/cloudflare/circl v1.6.1 // indirect
github.com/creack/pty v1.1.18 // indirect
github.com/cyphar/filepath-securejoin v0.5.0 // indirect
github.com/charmbracelet/bubbles v1.0.0 // indirect
github.com/charmbracelet/bubbletea v1.3.10 // indirect
github.com/charmbracelet/colorprofile v0.4.2 // indirect
github.com/charmbracelet/lipgloss v1.1.0 // indirect
github.com/charmbracelet/x/ansi v0.11.6 // indirect
github.com/charmbracelet/x/cellbuf v0.0.15 // indirect
github.com/charmbracelet/x/exp/strings v0.1.0 // indirect
github.com/charmbracelet/x/term v0.2.2 // indirect
github.com/clipperhouse/displaywidth v0.11.0 // indirect
github.com/clipperhouse/uax29/v2 v2.7.0 // indirect
github.com/cloudflare/circl v1.6.3 // indirect
github.com/cyphar/filepath-securejoin v0.6.1 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/emirpasic/gods v1.18.1 // indirect
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
github.com/go-git/go-billy/v5 v5.6.2 // indirect
github.com/go-git/go-billy/v5 v5.7.0 // indirect
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 // indirect
github.com/hinshun/vt10x v0.0.0-20220301184237-5011da428d02 // indirect
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
github.com/kevinburke/ssh_config v1.4.0 // indirect
github.com/kevinburke/ssh_config v1.6.0 // indirect
github.com/klauspost/cpuid/v2 v2.3.0 // indirect
github.com/lucasb-eyer/go-colorful v1.3.0 // indirect
github.com/mattn/go-localereader v0.0.1 // indirect
github.com/mattn/go-runewidth v0.0.20 // indirect
github.com/mitchellh/hashstructure/v2 v2.0.2 // indirect
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect
github.com/muesli/cancelreader v0.2.2 // indirect
github.com/muesli/termenv v0.16.0 // indirect
github.com/pjbgf/sha1cd v0.5.0 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/sergi/go-diff v1.4.0 // indirect
github.com/skeema/knownhosts v1.3.2 // indirect
github.com/xanzy/ssh-agent v0.3.3 // indirect
golang.org/x/crypto v0.45.0 // indirect
golang.org/x/net v0.47.0 // indirect
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
golang.org/x/crypto v0.48.0 // indirect
golang.org/x/net v0.50.0 // indirect
gopkg.in/warnings.v0 v0.1.2 // indirect
k8s.io/utils v0.0.0-20251002143259-bc988d571ff4 // indirect
k8s.io/utils v0.0.0-20260210185600-b8788abfbbc2 // indirect
)

require (
Expand All @@ -71,6 +95,6 @@ require (
github.com/stretchr/objx v0.5.3 // indirect
github.com/uber/jaeger-lib v2.4.1+incompatible // indirect
go.uber.org/atomic v1.11.0 // indirect
golang.org/x/term v0.37.0 // indirect
golang.org/x/term v0.40.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading
Loading