mirror of
https://github.com/opbnq-q/nto-cli.git
synced 2025-12-06 21:20:34 +07:00
feat: hide implement models from select
This commit is contained in:
52
cmd/input_dialog.go
Normal file
52
cmd/input_dialog.go
Normal file
@@ -0,0 +1,52 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"log"
|
||||
"nto_cli/utils"
|
||||
"os"
|
||||
|
||||
"github.com/rivo/tview"
|
||||
)
|
||||
|
||||
func SelectionInput() ([]string, string) {
|
||||
if len(os.Args) == 1 {
|
||||
log.Fatalf("Please provide path to models.go")
|
||||
}
|
||||
|
||||
modelsPath := os.Args[1]
|
||||
|
||||
structNames := utils.GetNotImplementedStructs(modelsPath)
|
||||
|
||||
if len(structNames) == 0 {
|
||||
log.Println("No unimplemented models -> nothing to do")
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
var result []string
|
||||
|
||||
app := tview.NewApplication()
|
||||
|
||||
form := tview.NewForm()
|
||||
var checkboxes []*tview.Checkbox
|
||||
|
||||
for _, name := range structNames {
|
||||
cb := tview.NewCheckbox().SetLabel(name)
|
||||
checkboxes = append(checkboxes, cb)
|
||||
form.AddFormItem(cb)
|
||||
}
|
||||
|
||||
form.AddButton("Generate", func() {
|
||||
for i, cb := range checkboxes {
|
||||
if cb.IsChecked() {
|
||||
result = append(result, structNames[i])
|
||||
}
|
||||
}
|
||||
app.Stop()
|
||||
})
|
||||
|
||||
if err := app.SetRoot(form, true).Run(); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
return result, modelsPath
|
||||
}
|
||||
Reference in New Issue
Block a user