Skip to content

Commit

Permalink
better main menu
Browse files Browse the repository at this point in the history
  • Loading branch information
rusq committed Jan 1, 2024
1 parent 56652ee commit ad6d400
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions cmd/slackdump/internal/wizard/wizard.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,22 +93,29 @@ func makeMenu(cmds []*base.Command, parent string, title string) (m *menu) {
}
if parent == "" {
m.Add(menuitem{
Name: "Exit",
Name: "Exit",
Description: "Exit the wizard",
})
} else {
m.Add(menuitem{
Name: "<< Back",
Name: "<< Back",
Description: "Go back to the previous menu",
})
}
return
}

func show(m *menu, onMatch func(cmd *base.Command) error) error {
var options []huh.Option[string]
for i, name := range m.names {
options = append(options, huh.NewOption(name+" - "+m.items[i].Description, name))
}
for {
var resp string
err := huh.NewSelect[string]().
Title(m.title).
Options(huh.NewOptions(m.names...)...).
// Options(huh.NewOptions(m.names...)...).
Options(options...).
Value(&resp).
Run()
if err != nil {
Expand Down

0 comments on commit ad6d400

Please sign in to comment.