diff options
Diffstat (limited to 'main.go')
| -rw-r--r-- | main.go | 41 |
1 files changed, 13 insertions, 28 deletions
@@ -10,6 +10,7 @@ package main import ( "errors" + "fmt" "os" "path/filepath" "strings" @@ -18,8 +19,6 @@ import ( "github.com/go-cmd/cmd" "go.wit.com/lib/gui/shell" "go.wit.com/log" - "golang.org/x/text/cases" - "golang.org/x/text/language" ) // sent via -ldflags @@ -45,9 +44,7 @@ func main() { if !shell.Exists(argv.Proto) { log.Info("protobuf", argv.Proto, "is missing") - if !argv.DryRun { - os.Exit(-1) - } + os.Exit(-1) } if !strings.HasSuffix(argv.Proto, ".proto") { @@ -113,11 +110,18 @@ func main() { // for `autogenpb: ` lines if err := pb.protoParse(f); err != nil { log.Info("autogenpb parse error:", err) - os.Exit(-1) + badExit(err) + } + + if f.Bases == nil { + badExit(fmt.Errorf("Base was nil. 'message %s {` did not exist", f.Filebase)) + } + if f.Base == nil { + badExit(fmt.Errorf("Base was nil. 'message %s {` did not exist", f.Filebase)) } if argv.DryRun { - os.Exit(0) + okExit("") } // try to make foo.pb.go with protoc if it's not here @@ -144,29 +148,10 @@ func main() { badExit(errors.New("failed to be created with protoc and proto-gen-go")) } + // make the marshal.pb.go file pb.marshal(f) - // this should be garbage soon - sortmap = make(map[string]string) - sortmap["package"] = packageName - sortmap["protofile"] = argv.Proto - sortmap["protobase"] = protobase - if argv.LoBase == "" { - // if not set, assumed to be protobase - sortmap["base"] = protobase - } else { - sortmap["base"] = argv.LoBase - } - sortmap["lock"] = sortmap["base"] + "sMu" // is nonglobal and plural - if argv.UpBase == "" { - sortmap["Base"] = cases.Title(language.English, cases.NoLower).String(protobase) - sortmap["Bases"] = sortmap["Base"] + "s" - } else { - sortmap["Base"] = argv.UpBase - sortmap["Bases"] = sortmap["Base"] + "s" - } - - // pb.makeSortfile(f) + // make the sort.pb.go file pb.makeNewSortfile(f) } |
