diff options
| author | Jeff Carr <[email protected]> | 2025-01-09 17:15:53 -0600 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-01-09 17:15:53 -0600 |
| commit | 948af64ea2b6e586f4d152fcfc7ed168dae4c919 (patch) | |
| tree | 8ac36eed2d783ee57eeb8f45c84adc75e8f7c8d4 /main.go | |
| parent | 7c10ff958e57d02d13287c4cdbe0aca3781e1600 (diff) | |
example doesn't seem to work. why? notsure
Signed-off-by: Jeff Carr <[email protected]>
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) } |
