feat: hide implement models from select

This commit is contained in:
2025-03-08 21:37:49 +07:00
parent e694fce7c7
commit fb59bf979c
6 changed files with 40 additions and 9 deletions

52
cmd/input_dialog.go Normal file
View 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
}