1414
1515package iostreams
1616
17- // Charm-based prompt implementations using the huh library.
18- // These are used when the "huh" experiment is enabled.
17+ // Interactive form-based prompt implementations with Charm's Huh package.
18+ //
19+ // Reference: https://github.com/charmbracelet/huh?tab=readme-ov-file#huh
1920
2021import (
2122 "context"
@@ -28,7 +29,7 @@ import (
2829 "github.com/slackapi/slack-cli/internal/style"
2930)
3031
31- // newForm wraps a field in a huh form, applying the Slack theme when the lipgloss experiment is enabled .
32+ // newForm wraps a field in an interactive form with optional Slack theming .
3233func newForm (io * IOStreams , field huh.Field ) * huh.Form {
3334 form := huh .NewForm (huh .NewGroup (field ))
3435 if io != nil && io .config .WithExperimentOn (experiment .Lipgloss ) {
@@ -37,7 +38,7 @@ func newForm(io *IOStreams, field huh.Field) *huh.Form {
3738 return form
3839}
3940
40- // buildInputForm constructs a huh form for text input prompts.
41+ // buildInputForm constructs an interactive form for text input prompts.
4142func buildInputForm (io * IOStreams , message string , cfg InputPromptConfig , input * string ) * huh.Form {
4243 field := huh .NewInput ().
4344 Title (message ).
@@ -50,8 +51,8 @@ func buildInputForm(io *IOStreams, message string, cfg InputPromptConfig, input
5051 return newForm (io , field )
5152}
5253
53- // charmInputPrompt prompts for text input using a charm huh form
54- func charmInputPrompt (io * IOStreams , _ context.Context , message string , cfg InputPromptConfig ) (string , error ) {
54+ // inputForm interactively prompts for text input.
55+ func inputForm (io * IOStreams , _ context.Context , message string , cfg InputPromptConfig ) (string , error ) {
5556 var input string
5657 err := buildInputForm (io , message , cfg , & input ).Run ()
5758 if errors .Is (err , huh .ErrUserAborted ) {
@@ -62,16 +63,16 @@ func charmInputPrompt(io *IOStreams, _ context.Context, message string, cfg Inpu
6263 return input , nil
6364}
6465
65- // buildConfirmForm constructs a huh form for yes/no confirmation prompts.
66+ // buildConfirmForm constructs an interactive form for yes/no confirmation prompts.
6667func buildConfirmForm (io * IOStreams , message string , choice * bool ) * huh.Form {
6768 field := huh .NewConfirm ().
6869 Title (message ).
6970 Value (choice )
7071 return newForm (io , field )
7172}
7273
73- // charmConfirmPrompt prompts for a yes/no confirmation using a charm huh form
74- func charmConfirmPrompt (io * IOStreams , _ context.Context , message string , defaultValue bool ) (bool , error ) {
74+ // confirmForm interactively prompts for a yes/no confirmation.
75+ func confirmForm (io * IOStreams , _ context.Context , message string , defaultValue bool ) (bool , error ) {
7576 var choice = defaultValue
7677 err := buildConfirmForm (io , message , & choice ).Run ()
7778 if errors .Is (err , huh .ErrUserAborted ) {
@@ -82,7 +83,7 @@ func charmConfirmPrompt(io *IOStreams, _ context.Context, message string, defaul
8283 return choice , nil
8384}
8485
85- // buildSelectForm constructs a huh form for single-selection prompts.
86+ // buildSelectForm constructs an interactive form for single-selection prompts.
8687func buildSelectForm (io * IOStreams , msg string , options []string , cfg SelectPromptConfig , selected * string ) * huh.Form {
8788 var opts []huh.Option [string ]
8889 for _ , opt := range options {
@@ -104,8 +105,8 @@ func buildSelectForm(io *IOStreams, msg string, options []string, cfg SelectProm
104105 return newForm (io , field )
105106}
106107
107- // charmSelectPrompt prompts the user to select one option using a charm huh form
108- func charmSelectPrompt (io * IOStreams , _ context.Context , msg string , options []string , cfg SelectPromptConfig ) (SelectPromptResponse , error ) {
108+ // selectForm interactively prompts the user to select one option.
109+ func selectForm (io * IOStreams , _ context.Context , msg string , options []string , cfg SelectPromptConfig ) (SelectPromptResponse , error ) {
109110 var selected string
110111 err := buildSelectForm (io , msg , options , cfg , & selected ).Run ()
111112 if errors .Is (err , huh .ErrUserAborted ) {
@@ -118,7 +119,7 @@ func charmSelectPrompt(io *IOStreams, _ context.Context, msg string, options []s
118119 return SelectPromptResponse {Prompt : true , Index : index , Option : selected }, nil
119120}
120121
121- // buildPasswordForm constructs a huh form for password (hidden input) prompts.
122+ // buildPasswordForm constructs an interactive form for password (hidden input) prompts.
122123func buildPasswordForm (io * IOStreams , message string , cfg PasswordPromptConfig , input * string ) * huh.Form {
123124 field := huh .NewInput ().
124125 Title (message ).
@@ -131,8 +132,8 @@ func buildPasswordForm(io *IOStreams, message string, cfg PasswordPromptConfig,
131132 return newForm (io , field )
132133}
133134
134- // charmPasswordPrompt prompts for a password ( hidden input) using a charm huh form
135- func charmPasswordPrompt (io * IOStreams , _ context.Context , message string , cfg PasswordPromptConfig ) (PasswordPromptResponse , error ) {
135+ // passwordForm interactively prompts for a password with hidden input.
136+ func passwordForm (io * IOStreams , _ context.Context , message string , cfg PasswordPromptConfig ) (PasswordPromptResponse , error ) {
136137 var input string
137138 err := buildPasswordForm (io , message , cfg , & input ).Run ()
138139 if errors .Is (err , huh .ErrUserAborted ) {
@@ -143,7 +144,7 @@ func charmPasswordPrompt(io *IOStreams, _ context.Context, message string, cfg P
143144 return PasswordPromptResponse {Prompt : true , Value : input }, nil
144145}
145146
146- // buildMultiSelectForm constructs a huh form for multiple-selection prompts.
147+ // buildMultiSelectForm constructs an interactive form for multiple-selection prompts.
147148func buildMultiSelectForm (io * IOStreams , message string , options []string , selected * []string ) * huh.Form {
148149 var opts []huh.Option [string ]
149150 for _ , opt := range options {
@@ -158,8 +159,8 @@ func buildMultiSelectForm(io *IOStreams, message string, options []string, selec
158159 return newForm (io , field )
159160}
160161
161- // charmMultiSelectPrompt prompts the user to select multiple options using a charm huh form
162- func charmMultiSelectPrompt (io * IOStreams , _ context.Context , message string , options []string ) ([]string , error ) {
162+ // multiSelectForm interactively prompts the user to select multiple options.
163+ func multiSelectForm (io * IOStreams , _ context.Context , message string , options []string ) ([]string , error ) {
163164 var selected []string
164165 err := buildMultiSelectForm (io , message , options , & selected ).Run ()
165166 if errors .Is (err , huh .ErrUserAborted ) {
0 commit comments