mirror of
https://github.com/opbnq-q/nto-cli.git
synced 2025-12-06 17:00:33 +07:00
feat: new parser & generator
This commit is contained in:
19
main.go
19
main.go
@@ -4,21 +4,20 @@ import (
|
||||
"log"
|
||||
"nto_cli/cmd"
|
||||
"nto_cli/generation"
|
||||
"nto_cli/model"
|
||||
"nto_cli/utils"
|
||||
"os"
|
||||
)
|
||||
|
||||
func main() {
|
||||
log.SetFlags(0)
|
||||
structNames, path := cmd.SelectionInput()
|
||||
modelsPath := utils.GetModelsPath()
|
||||
models, err := model.ParseModelsPackage(modelsPath)
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to parse models: %s", err)
|
||||
}
|
||||
selectedModels := cmd.SelectionInput(models)
|
||||
|
||||
for _, structName := range structNames {
|
||||
file, err := os.Open(path)
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to open file: %s", err)
|
||||
}
|
||||
structFields := utils.GetStructFields(file, structName)
|
||||
_ = file.Close()
|
||||
generation.Generate(structName, structFields)
|
||||
for _, m := range *selectedModels {
|
||||
generation.Generate(&m)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user