summaryrefslogtreecommitdiff
path: root/protoReformat.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-03-29 11:55:54 -0500
committerJeff Carr <[email protected]>2025-03-29 11:55:54 -0500
commit79e59bef1164b0c6ebeea9f040438d1b9caa1aaf (patch)
treebbb6414d924a2b3e520da6d2b43331b3362cd1db /protoReformat.go
parent0a97886cd2e942070ac478b2802f49dca8249f36 (diff)
used autogenpb to reformat file.proto
Diffstat (limited to 'protoReformat.go')
-rw-r--r--protoReformat.go47
1 files changed, 29 insertions, 18 deletions
diff --git a/protoReformat.go b/protoReformat.go
index efd568b..af64f87 100644
--- a/protoReformat.go
+++ b/protoReformat.go
@@ -29,17 +29,6 @@ type StdMessage struct {
all []Message
}
-func (msg *EnumMessage) name() string {
- return "fuckit enum"
-}
-
-func (msg *StdMessage) name() string {
- if msg.msgPB != nil {
- return msg.msgPB.Header
- }
- return "fuckit std"
-}
-
type Message interface {
name() string
load()
@@ -197,7 +186,7 @@ func newDepth(fmtmsg *FormatMsg, header string) *FormatMsg {
newmsg := new(FormatMsg)
newmsg.MaxVarname = fmtmsg.MaxVarname
newmsg.MaxVartype = fmtmsg.MaxVartype
- newmsg.Header = header
+ newmsg.Header = strings.TrimSpace(header)
newmsg.Depth = fmtmsg.Depth + 1
return newmsg
@@ -364,18 +353,40 @@ func (msg *FormatMsg) pad() string {
return pad
}
+func (msg *FormatMsg) padding(offset int) string {
+ var pad string
+ for i := offset; i < int(msg.Depth); i += 1 {
+ pad += fmt.Sprintf("%8s", " ")
+ }
+ return pad
+}
+
func formatEnum(curmsg *FormatMsg) []string {
var newmsg []string
- header := fmt.Sprintf("%s%s // enum depth=%d", curmsg.padBase(), curmsg.Header, curmsg.Depth)
- newmsg = append(newmsg, header)
+ if argv.Debug {
+ header := fmt.Sprintf("%s%s // enum2 depth=%d", curmsg.padBase(), curmsg.Header, curmsg.Depth)
+ newmsg = append(newmsg, header)
+ header = fmt.Sprintf("//%s//%s// enum2 depth=%d", curmsg.padding(2), curmsg.Header, curmsg.Depth)
+ newmsg = append(newmsg, header)
+ header = fmt.Sprintf("// %s", curmsg.Header)
+ newmsg = append(newmsg, header)
+ } else {
+ header := fmt.Sprintf("%s%s", curmsg.padBase(), curmsg.Header)
+ newmsg = append(newmsg, header)
+ }
for _, line := range curmsg.Lines {
line = fmt.Sprintf("%s%s", curmsg.pad(), line)
newmsg = append(newmsg, line)
}
- footer := fmt.Sprintf("%s%s // enum footer depth=%d", curmsg.padBase(), curmsg.Footer, curmsg.Depth)
- newmsg = append(newmsg, footer)
+ if argv.Debug {
+ footer := fmt.Sprintf("%s%s // enum2 footer depth=%d", curmsg.padBase(), curmsg.Footer, curmsg.Depth)
+ newmsg = append(newmsg, footer)
+ } else {
+ footer := fmt.Sprintf("%s%s", curmsg.padBase(), curmsg.Footer)
+ newmsg = append(newmsg, footer)
+ }
return newmsg
}
@@ -465,12 +476,12 @@ func formatMessage(curmsg *FormatMsg) []string {
switch msg.Type {
case FormatMsg_ENUM:
for _, line := range formatEnum(msg) {
- line = fmt.Sprintf("%s%s", curmsg.pad(), line)
+ // line = fmt.Sprintf("%s%s", curmsg.pad(), line)
newmsg = append(newmsg, line)
}
case FormatMsg_MESSAGE:
for _, line := range msg.format() {
- line = fmt.Sprintf("%s%s", curmsg.pad(), line)
+ // line = fmt.Sprintf("%s%s", curmsg.pad(), line)
newmsg = append(newmsg, line)
}
default: