summaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'main.go')
-rw-r--r--main.go29
1 files changed, 16 insertions, 13 deletions
diff --git a/main.go b/main.go
index 00dd720..705b46e 100644
--- a/main.go
+++ b/main.go
@@ -31,6 +31,7 @@ func main() {
// you need a proto file
if argv.Proto == "" {
log.Info("you must provide --proto <filename>")
+ pp.WriteHelp(os.Stdout)
os.Exit(-1)
}
@@ -46,24 +47,28 @@ func main() {
os.Exit(-1)
}
- // you need --upbase and --lobase
- if argv.Proto == "" {
- pp.WriteHelp(os.Stdout)
+ if err := findGlobalAutogenpb(argv.Proto); err != nil {
+ log.Info("autogenpb parse error:", err)
os.Exit(-1)
}
if !shell.Exists("go.sum") {
- shell.Run([]string{"go", "mod", "init"})
- shell.Run([]string{"go", "mod", "tidy"})
+ shell.RunQuiet([]string{"go", "mod", "init"})
+ shell.RunQuiet([]string{"go", "mod", "tidy"})
+ shell.RunQuiet([]string{"go", "mod", "edit", "-go=1.18"}) // TODO: make this a global
}
+ // TODO: switch to using forgepb
+ // switch to forgepb
+ os.Setenv("GO111MODULE", "off") // keeps go list working if go version is back versioned for compatability
cmd := []string{"go", "list", "-f", "'{{.Name}}'"}
- result := shell.Run(cmd)
+ result := shell.RunQuiet(cmd)
+ os.Unsetenv("GO111MODULE")
packageName := strings.Join(result.Stdout, "\n")
packageName = strings.TrimSpace(packageName)
packageName = strings.Trim(packageName, "'")
- log.Info("packageName == ", packageName)
+ // log.Info("packageName == ", packageName)
protobase := strings.TrimSuffix(argv.Proto, ".proto")
@@ -112,11 +117,11 @@ func main() {
// seems to work, but proto.Marshal() breaks with nil reference
if argv.Mutex {
if err := addMutex(sortmap); err == nil {
- log.Info("adding mutex to existing protoc-gen-go file worked")
+ // log.Info("adding mutex to existing protoc-gen-go file worked")
sortmap["mutex"] = "true"
sortmap["lock"] = "all"
} else {
- log.Info("adding mutex to existing protoc-gen-go file did not work")
+ log.Info("adding mutex to existing protoc-gen-go file did not work", err)
sortmap["mutex"] = "false"
}
}
@@ -130,7 +135,7 @@ func main() {
}
if argv.NoSort {
- log.Info("not making sort.pb.go file (--no-sort == true)")
+ // log.Info("not making sort.pb.go file (--no-sort == true)")
} else {
if len(uniqueKeys) != 0 {
}
@@ -138,10 +143,8 @@ func main() {
}
if argv.NoMarshal {
- log.Info("not making marshal.pb.go file (--no-marshal == true)")
+ // log.Info("not making marshal.pb.go file (--no-marshal == true)")
} else {
- if len(marshalKeys) != 0 {
- }
// make the foo.marshal.pb.go file
marshal(sortmap)
}