dorfylegends/analyze/analyze.go

55 lines
883 B
Go
Raw Normal View History

2022-04-14 16:58:28 +03:00
package main
2022-04-13 08:28:07 +03:00
import (
2022-04-14 17:06:17 +03:00
"flag"
2022-04-15 16:27:51 +03:00
"log"
2022-04-13 08:28:07 +03:00
2022-04-14 18:39:18 +03:00
"github.com/robertjanetzko/LegendsBrowser2/analyze/df"
2022-04-13 08:28:07 +03:00
)
2022-04-14 17:06:17 +03:00
func main() {
2022-04-30 10:04:33 +03:00
f := flag.String("a", "", "analyze files")
l := flag.Bool("l", false, "load previous analyze data")
2022-04-14 17:06:17 +03:00
g := flag.Bool("g", false, "generate model")
2022-04-18 18:26:14 +03:00
e := flag.Bool("e", false, "regenerate events")
2022-04-14 17:06:17 +03:00
flag.Parse()
2022-04-30 10:04:33 +03:00
if len(*f) > 0 {
var a *df.AnalyzeData
var err error
if *l {
a, err = df.LoadAnalyzeData()
if err != nil {
log.Fatal(err)
}
}
df.AnalyzeStructure(*f, a)
2022-04-14 17:06:17 +03:00
}
if *g {
2022-04-25 21:16:49 +03:00
df.LoadSameFields()
2022-04-18 18:26:14 +03:00
a, err := df.LoadAnalyzeData()
2022-04-15 16:27:51 +03:00
if err != nil {
log.Fatal(err)
}
2022-04-18 18:26:14 +03:00
df.ListEnumCandidates(a)
m, err := df.CreateMetadata(a)
if err != nil {
log.Fatal(err)
}
if err := df.GenerateBackendCode(m); err != nil {
log.Fatal(err)
}
if *e {
if err := df.GenerateEventsCode(m); err != nil {
log.Fatal(err)
}
}
2022-04-14 17:06:17 +03:00
}
}