Skip to content
Open
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
30 changes: 18 additions & 12 deletions cmd/scheduledTasks.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"strconv"
"strings"

"github.com/AlecAivazis/survey/v2"
"github.com/charmbracelet/huh"
"github.com/apppackio/apppack/app"
"github.com/apppackio/apppack/ui"
"github.com/logrusorgru/aurora"
Expand Down Expand Up @@ -123,20 +123,26 @@ If no index is provided, an interactive prompt will be provided to choose the ta
for _, t := range tasks {
taskList = append(taskList, fmt.Sprintf("%s %s", t.Schedule, t.Command))
}
questions := []*survey.Question{{
Name: "task",
Prompt: &survey.Select{
Message: "Scheduled task to delete:",
Options: taskList,
FilterMessage: "",
},
}}
answers := make(map[string]int)
var selectedTask string
form := huh.NewForm(
huh.NewGroup(
huh.NewSelect[string]().
Title("Scheduled task to delete:").
Options(huh.NewOptions(taskList...)...).
Value(&selectedTask),
),
)
ui.Spinner.Stop()
if err := survey.Ask(questions, &answers); err != nil {
if err := form.Run(); err != nil {
checkErr(err)
}
idx = answers["task"]
// Find index of selected task
for i, task := range taskList {
if task == selectedTask {
idx = i
break
}
}
}
task, err = a.DeleteScheduledTask(idx)
checkErr(err)
Expand Down
33 changes: 20 additions & 13 deletions cmd/shell.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"strings"
"time"

"github.com/AlecAivazis/survey/v2"
"github.com/charmbracelet/huh"
"github.com/apppackio/apppack/app"
"github.com/apppackio/apppack/ui"
"github.com/aws/aws-sdk-go/aws"
Expand Down Expand Up @@ -147,23 +147,30 @@ func interactiveCmd(a *app.App, cmd string) {
arnParts := strings.Split(*t.TaskArn, "/")
taskList = append(taskList, fmt.Sprintf("%s: %s", *tag, arnParts[len(arnParts)-1]))
}
answers := make(map[string]interface{})
questions := []*survey.Question{
{
Name: "task",
Prompt: &survey.Select{
Message: "Select task to connect to",
Options: taskList,
},
},
}
var selectedTask string
form := huh.NewForm(
huh.NewGroup(
huh.NewSelect[string]().
Title("Select task to connect to").
Options(huh.NewOptions(taskList...)...).
Value(&selectedTask),
),
)
ui.Spinner.Stop()
if err := survey.Ask(questions, &answers); err != nil {
if err := form.Run(); err != nil {
checkErr(err)
}
// Find index of selected task
var selectedIndex int
for i, task := range taskList {
if task == selectedTask {
selectedIndex = i
break
}
}
ui.StartSpinner()
ecsSession, err := a.CreateEcsSession(
tasks[answers["task"].(survey.OptionAnswer).Index],
tasks[selectedIndex],
exec,
)
checkErr(err)
Expand Down
27 changes: 20 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ module github.com/apppackio/apppack
go 1.22

require (
github.com/AlecAivazis/survey/v2 v2.3.7
github.com/TylerBrock/saw v0.2.2
github.com/apparentlymart/go-cidr v1.1.0
github.com/aws/aws-sdk-go v1.51.7
github.com/briandowns/spinner v1.23.0
github.com/charmbracelet/huh v0.6.0
github.com/dustin/go-humanize v1.0.1
github.com/getsentry/sentry-go v0.27.0
github.com/google/uuid v1.6.0
Expand All @@ -30,13 +30,28 @@ require (
)

require (
github.com/atotto/clipboard v0.1.4 // indirect
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
github.com/catppuccin/go v0.2.0 // indirect
github.com/charmbracelet/bubbles v0.20.0 // indirect
github.com/charmbracelet/bubbletea v1.1.0 // indirect
github.com/charmbracelet/lipgloss v0.13.0 // indirect
github.com/charmbracelet/x/ansi v0.2.3 // indirect
github.com/charmbracelet/x/exp/strings v0.0.0-20240722160745-212f7b056ed0 // indirect
github.com/charmbracelet/x/term v0.2.0 // indirect
github.com/cihub/seelog v0.0.0-20170130134532-f561c5e57575 // indirect
github.com/eiannone/keyboard v0.0.0-20220611211555-0d226195f203 // indirect
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/gorilla/websocket v1.4.2 // indirect
github.com/mattn/go-localereader v0.0.1 // 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.15.3-0.20240618155329-98d742f6907a // indirect
github.com/twinj/uuid v0.0.0-20151029044442-89173bcdda19 // indirect
github.com/xtaci/smux v1.5.24 // indirect
golang.org/x/sync v0.1.0 // indirect
golang.org/x/sync v0.8.0 // indirect
)

require (
Expand All @@ -51,21 +66,19 @@ require (
github.com/hokaccha/go-prettyjson v0.0.0-20190818114111-108c894c2c0e // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
github.com/lunixbochs/vtclean v1.0.0 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-runewidth v0.0.15 // indirect
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect
github.com/mattn/go-runewidth v0.0.16 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/stretchr/objx v0.5.0 // indirect
golang.org/x/crypto v0.21.0 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/sys v0.25.0 // indirect
golang.org/x/term v0.18.0 // indirect
golang.org/x/text v0.14.0
golang.org/x/text v0.18.0
gopkg.in/yaml.v3 v3.0.1 // indirect
)

Expand Down
Loading
Loading