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
2 changes: 2 additions & 0 deletions .claude/settings.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{
"permissions": {
"allow": [
"Bash(go build:*)",
"Bash(go mod tidy:*)",
"Bash(go test:*)",
Comment on lines +4 to +6
Copy link
Member

Choose a reason for hiding this comment

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

🔋 ⚡

Copy link
Member Author

Choose a reason for hiding this comment

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

@mwbrooks @claude Kept asking me to build particular packages. I keep saying "yes" of course but now I hope it's known 🪬

"Bash(gofmt:*)",
"Bash(gh issue view:*)",
"Bash(gh label list:*)",
Expand Down
5 changes: 0 additions & 5 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"strings"
"syscall"

huh "charm.land/huh/v2"
"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 @@ -149,10 +148,6 @@ 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)

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

Expand Down
22 changes: 17 additions & 5 deletions internal/iostreams/charm.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ package iostreams

import (
"context"
"errors"
"slices"

huh "charm.land/huh/v2"
"github.com/slackapi/slack-cli/internal/slackerror"
"github.com/slackapi/slack-cli/internal/style"
)

Expand All @@ -42,7 +44,9 @@ func buildInputForm(message string, cfg InputPromptConfig, input *string) *huh.F
func charmInputPrompt(_ *IOStreams, _ context.Context, message string, cfg InputPromptConfig) (string, error) {
var input string
err := buildInputForm(message, cfg, &input).Run()
if err != nil {
if errors.Is(err, huh.ErrUserAborted) {
return "", slackerror.New(slackerror.ErrProcessInterrupted)
} else if err != nil {
return "", err
}
return input, nil
Expand All @@ -60,7 +64,9 @@ func buildConfirmForm(message string, choice *bool) *huh.Form {
func charmConfirmPrompt(_ *IOStreams, _ context.Context, message string, defaultValue bool) (bool, error) {
var choice = defaultValue
err := buildConfirmForm(message, &choice).Run()
if err != nil {
if errors.Is(err, huh.ErrUserAborted) {
return false, slackerror.New(slackerror.ErrProcessInterrupted)
} else if err != nil {
return false, err
}
return choice, nil
Expand Down Expand Up @@ -92,7 +98,9 @@ func buildSelectForm(msg string, options []string, cfg SelectPromptConfig, selec
func charmSelectPrompt(_ *IOStreams, _ context.Context, msg string, options []string, cfg SelectPromptConfig) (SelectPromptResponse, error) {
var selected string
err := buildSelectForm(msg, options, cfg, &selected).Run()
if err != nil {
if errors.Is(err, huh.ErrUserAborted) {
return SelectPromptResponse{}, slackerror.New(slackerror.ErrProcessInterrupted)
} else if err != nil {
return SelectPromptResponse{}, err
}

Expand All @@ -117,7 +125,9 @@ func buildPasswordForm(message string, cfg PasswordPromptConfig, input *string)
func charmPasswordPrompt(_ *IOStreams, _ context.Context, message string, cfg PasswordPromptConfig) (PasswordPromptResponse, error) {
var input string
err := buildPasswordForm(message, cfg, &input).Run()
if err != nil {
if errors.Is(err, huh.ErrUserAborted) {
return PasswordPromptResponse{}, slackerror.New(slackerror.ErrProcessInterrupted)
} else if err != nil {
return PasswordPromptResponse{}, err
}
return PasswordPromptResponse{Prompt: true, Value: input}, nil
Expand All @@ -142,7 +152,9 @@ func buildMultiSelectForm(message string, options []string, selected *[]string)
func charmMultiSelectPrompt(_ *IOStreams, _ context.Context, message string, options []string) ([]string, error) {
var selected []string
err := buildMultiSelectForm(message, options, &selected).Run()
if err != nil {
if errors.Is(err, huh.ErrUserAborted) {
return []string{}, slackerror.New(slackerror.ErrProcessInterrupted)
} else if err != nil {
return []string{}, err
}
return selected, nil
Expand Down
Loading