summaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-10-14 17:23:28 -0500
committerJeff Carr <[email protected]>2025-10-14 17:23:28 -0500
commitb7c2f78414f1b7113d4f760b81b51d7b6758ea35 (patch)
tree40fe3cc827ee7d88e19a19667292df419f52c4b0 /main.go
parentc182558c57fcc02314dbb109b8e515c37a8e00a9 (diff)
run only on os.Stat(). hopefully helps go generatev0.5.24
Diffstat (limited to 'main.go')
-rw-r--r--main.go36
1 files changed, 26 insertions, 10 deletions
diff --git a/main.go b/main.go
index f07182b..8f97dd8 100644
--- a/main.go
+++ b/main.go
@@ -32,11 +32,9 @@ var BUILDTIME string
var ARGNAME string = "autogenpb"
-// var fsort *os.File // the sort.pb.go output file
-
func main() {
me = new(mainType)
- me.sh = prep.Bash(&argv) // add support for bash autocomplete with go-arg
+ me.sh = prep.Autocomplete(&argv) // adds shell auto complete to go-args
me.pb = new(Files)
if argv.Identify != "" {
@@ -67,13 +65,31 @@ func main() {
}
func doProto(argvProto string) error {
- if argv.Format {
+ pf := new(File)
+ me.pb.Files = append(me.pb.Files, pf)
+ pf.Filename = argvProto
+ pf.IterMap = make(map[string]string)
+
+ pf.Filebase = strings.TrimSuffix(argvProto, ".proto")
+
+ if argv.Clean {
+ doClean(pf.Filebase)
+ me.sh.GoodExit("doClean() ran")
+ }
+
+ if argv.Ctime {
+ doCtime(pf.Filebase)
+ me.sh.GoodExit("doClean() ran")
+ }
+
+ if argv.ReFormat {
protoReformatComments(argvProto)
// time.Sleep(5 * time.Second)
protoReformat(argvProto)
log.Info("format done")
okExit("")
}
+
if argv.Comments {
protoReformatComments(argvProto)
okExit("")
@@ -84,12 +100,12 @@ func doProto(argvProto string) error {
os.Setenv("PROTOBUF_REGRET", "true")
}
- pf := new(File)
- me.pb.Files = append(me.pb.Files, pf)
- pf.Filename = argvProto
- pf.IterMap = make(map[string]string)
-
- pf.Filebase = strings.TrimSuffix(argvProto, ".proto")
+ if doCtime(pf.Filebase) {
+ log.Info("nothing changed. exit here")
+ me.sh.GoodExit("doCtime() ran")
+ } else {
+ log.Info("ctime check: need to re-run autogenpb")
+ }
// parse sort & marshal options from the .proto file
// this goes through the .proto files and looks