From b4df5436ec87711fd548c3106968fbcf0cdd75b4 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Wed, 2 Apr 2025 12:33:29 -0500 Subject: [PATCH] more cleanups. now to add oneof --- protoReformat.go | 29 +++++------------------------ 1 file changed, 5 insertions(+), 24 deletions(-) diff --git a/protoReformat.go b/protoReformat.go index d38b61e..bafdea6 100644 --- a/protoReformat.go +++ b/protoReformat.go @@ -302,32 +302,13 @@ func (msg *FormatMsg) padding(offset int) string { func formatEnum(curmsg *FormatMsg) []string { var newmsg []string - 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) - } + newmsg = append(newmsg, curmsg.formatLineBase(curmsg.Header, "enum header")) for _, line := range curmsg.Lines { - line = fmt.Sprintf("%s%s", curmsg.pad(), line) - newmsg = append(newmsg, line) + newmsg = append(newmsg, curmsg.formatLine(line, "enum")) } - 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) - } + newmsg = append(newmsg, curmsg.formatLineBase(curmsg.Footer, "enum header")) return newmsg } @@ -375,7 +356,7 @@ func (all *FormatMsg) format() []string { func (msg *FormatMsg) formatLineBase(line string, dbg string) string { line = strings.TrimSpace(line) if argv.Debug { - return fmt.Sprintf("%s%s // %s depth=%d", msg.padBase(), line, dbg, msg.Depth) + return fmt.Sprintf("/*a*/ %s%s // %s depth=%d", msg.padBase(), line, dbg, msg.Depth) } return fmt.Sprintf("%s%s", msg.padBase(), line) } @@ -383,7 +364,7 @@ func (msg *FormatMsg) formatLineBase(line string, dbg string) string { func (msg *FormatMsg) formatLine(line string, dbg string) string { line = strings.TrimSpace(line) if argv.Debug { - return fmt.Sprintf("%s%s // %s depth=%d", msg.pad(), line, dbg, msg.Depth) + return fmt.Sprintf("/*a*/ %s%s // %s depth=%d", msg.pad(), line, dbg, msg.Depth) } return fmt.Sprintf("%s%s", msg.padBase(), line) }