Skip to content

Commit

Permalink
Merge pull request #341 from rusq/ui
Browse files Browse the repository at this point in the history
UI wording
  • Loading branch information
rusq authored Oct 25, 2024
2 parents 9332577 + cfe1443 commit 8874833
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
2 changes: 1 addition & 1 deletion cmd/slackdump/internal/archive/wizard.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

func archiveWizard(ctx context.Context, cmd *base.Command, args []string) error {
w := &dumpui.Wizard{
Title: "Archive Slackdump workspace",
Title: "Archive Slack Workspace",
Particulars: "Archive",
Cmd: cmd,
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/slackdump/internal/export/wizard.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

func wizExport(ctx context.Context, cmd *base.Command, args []string) error {
w := &dumpui.Wizard{
Title: "Export Slackdump workspace",
Title: "Export Slack Workspace",
Particulars: "Export",
Cmd: cmd,
}
Expand Down
26 changes: 16 additions & 10 deletions cmd/slackdump/internal/ui/dumpui/dumpui.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,15 @@ type Wizard struct {
Cmd *base.Command
}

const (
actRun = "run"
actConfig = "config"
actExit = "exit"
)

func (w *Wizard) Run(ctx context.Context) error {
var (
action string = "run"
action string = actRun
)

menu := func() *huh.Form {
Expand All @@ -28,10 +34,10 @@ func (w *Wizard) Run(ctx context.Context) error {
huh.NewSelect[string]().
Title(w.Title).
Options(
huh.NewOption("Run "+w.Particulars, "run"),
huh.NewOption("Configuration", "config"),
huh.NewOption("Run "+w.Particulars, actRun),
huh.NewOption("Configuration...", actConfig),
huh.NewOption(ui.MenuSeparator, ""),
huh.NewOption("Exit to Main Menu", "exit"),
huh.NewOption("<< Exit to Main Menu", actExit),
).Value(&action),
),
).WithTheme(ui.HuhTheme).WithAccessible(cfg.AccessibleMode)
Expand All @@ -43,16 +49,16 @@ LOOP:
return err
}
switch action {
case "exit":
break LOOP
case "config":
if err := cfgui.Show(ctx); err != nil {
case actRun:
if err := w.Cmd.Run(ctx, w.Cmd, nil); err != nil {
return err
}
case "run":
if err := w.Cmd.Run(ctx, w.Cmd, nil); err != nil {
case actConfig:
if err := cfgui.Show(ctx); err != nil {
return err
}
case actExit:
break LOOP
}
}

Expand Down

0 comments on commit 8874833

Please sign in to comment.