-
-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #345 from rusq/ui
ui
- Loading branch information
Showing
42 changed files
with
1,347 additions
and
258 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
package diag | ||
|
||
import ( | ||
"context" | ||
|
||
tea "github.com/charmbracelet/bubbletea" | ||
"github.com/charmbracelet/huh" | ||
"github.com/rusq/slackdump/v3/cmd/slackdump/internal/golang/base" | ||
"github.com/rusq/slackdump/v3/cmd/slackdump/internal/ui/cfgui" | ||
"github.com/rusq/slackdump/v3/cmd/slackdump/internal/ui/dumpui" | ||
) | ||
|
||
var CmdWizDebug = &base.Command{ | ||
UsageLine: "slackdump tools wizdebug", | ||
Short: "run the wizard debug command", | ||
Run: runWizDebug, | ||
PrintFlags: true, | ||
} | ||
|
||
type wdWhat int | ||
|
||
const ( | ||
wdExit wdWhat = iota | ||
wdDumpUI | ||
wdConfigUI | ||
) | ||
|
||
func runWizDebug(ctx context.Context, cmd *base.Command, args []string) error { | ||
var action wdWhat | ||
for { | ||
form := huh.NewForm( | ||
huh.NewGroup( | ||
huh.NewSelect[wdWhat]().Options( | ||
huh.NewOption("Dump UI", wdDumpUI), | ||
huh.NewOption("Global Config UI", wdConfigUI), | ||
).Value(&action), | ||
).WithHeight(10), | ||
) | ||
|
||
if err := form.RunWithContext(ctx); err != nil { | ||
return err | ||
} | ||
switch action { | ||
case wdDumpUI: | ||
if err := debugDumpUI(ctx); err != nil { | ||
return err | ||
} | ||
case wdConfigUI: | ||
if err := debugConfigUI(ctx); err != nil { | ||
return err | ||
} | ||
case wdExit: | ||
return nil | ||
} | ||
} | ||
} | ||
|
||
func debugDumpUI(ctx context.Context) error { | ||
menu := []dumpui.MenuItem{ | ||
{ | ||
ID: "run", | ||
Name: "Run", | ||
Help: "Run the command", | ||
}, | ||
{ | ||
Name: "Global Configuration...", | ||
Help: "Set global configuration options", | ||
Model: cfgui.NewConfigUI(cfgui.DefaultStyle(), cfgui.GlobalConfig), | ||
}, | ||
{ | ||
Name: "Local Configuration...", | ||
Help: "Set command specific configuration options", | ||
}, | ||
{ | ||
Separator: true, | ||
}, | ||
{ | ||
Name: "Exit", | ||
Help: "Exit to main menu", | ||
}, | ||
} | ||
w := dumpui.NewModel("Wizard Debug", menu, false) | ||
|
||
if _, err := tea.NewProgram(w, tea.WithContext(ctx)).Run(); err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func debugConfigUI(ctx context.Context) error { | ||
return cfgui.Global(ctx) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.