Skip to content

Commit 9e3e325

Browse files
snay2GavinBurris42
andauthored
Use Bubble Tea for interactive mode UX (#100)
* Use Bubble Tea models for the interactive questionnaires Co-authored-by: Gavin <[email protected]> * Improve Ctrl+C handling when asking a single instance ID * Update confirmation message to indicate whether user can change their answers (available only in interactive mode) * New method for asserting array equivalence, regardless of item order, whitespace, or string case This fixes flakiness in two tests: TestAskUserTags_WithDefault and TestAskSecurityGroups_Success Co-authored-by: Gavin <[email protected]>
1 parent f7b037b commit 9e3e325

File tree

10 files changed

+1589
-1048
lines changed

10 files changed

+1589
-1048
lines changed

cmd/connect.go

+6-4
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"simple-ec2/pkg/ec2helper"
2323
ec2ichelper "simple-ec2/pkg/ec2instanceconnecthelper"
2424
"simple-ec2/pkg/question"
25+
"simple-ec2/pkg/questionModel"
2526

2627
"github.com/aws/aws-sdk-go/aws/session"
2728
"github.com/spf13/cobra"
@@ -56,16 +57,17 @@ func connect(cmd *cobra.Command, args []string) {
5657
sess := session.Must(session.NewSessionWithOptions(session.Options{SharedConfigState: session.SharedConfigEnable}))
5758
ec2helper.GetDefaultRegion(sess)
5859
h := ec2helper.New(sess)
60+
qh := questionModel.NewQuestionModelHelper()
5961

6062
if isInteractive {
61-
connectInteractive(h)
63+
connectInteractive(h, qh)
6264
} else {
6365
connectNonInteractive(h)
6466
}
6567
}
6668

6769
// Connect instances interactively
68-
func connectInteractive(h *ec2helper.EC2Helper) {
70+
func connectInteractive(h *ec2helper.EC2Helper, qh *questionModel.QuestionModelHelper) {
6971
// If region is not specified in flags, ask region
7072
var region *string
7173
var err error
@@ -75,7 +77,7 @@ func connectInteractive(h *ec2helper.EC2Helper) {
7577
if cli.ShowError(err, "Default config file not loaded; using system defaults instead") {
7678
defaultsConfig = config.NewSimpleInfo()
7779
}
78-
region, err = question.AskRegion(h, defaultsConfig.Region)
80+
region, err = question.AskRegion(h, qh, defaultsConfig.Region)
7981
if cli.ShowError(err, "Asking region failed") {
8082
return
8183
}
@@ -86,7 +88,7 @@ func connectInteractive(h *ec2helper.EC2Helper) {
8688
h.ChangeRegion(*region)
8789

8890
// Ask instance ID
89-
instanceId, err := question.AskInstanceId(h)
91+
instanceId, err := question.AskInstanceId(h, qh)
9092
if cli.ShowError(err, "Asking instance ID failed") {
9193
return
9294
}

0 commit comments

Comments
 (0)