closer to back to working again
This commit is contained in:
parent
dfe42d8d23
commit
11ccc557fe
|
@ -110,7 +110,7 @@ proto-reformat-comments:
|
||||||
../autogenpb --proto signal.proto --format-comments
|
../autogenpb --proto signal.proto --format-comments
|
||||||
|
|
||||||
proto-reformat-full:
|
proto-reformat-full:
|
||||||
autogenpb --proto signal.proto --format
|
../autogenpb --proto signal.proto --format
|
||||||
|
|
||||||
proto-reformat-fruit:
|
proto-reformat-fruit:
|
||||||
autogenpb --proto fruit.proto --format
|
../autogenpb --proto fruit.proto --format
|
||||||
|
|
4
main.go
4
main.go
|
@ -18,7 +18,6 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/alexflint/go-arg"
|
"github.com/alexflint/go-arg"
|
||||||
"github.com/go-cmd/cmd"
|
"github.com/go-cmd/cmd"
|
||||||
|
@ -65,8 +64,9 @@ func main() {
|
||||||
|
|
||||||
if argv.Format {
|
if argv.Format {
|
||||||
protoReformatComments(argv.Proto)
|
protoReformatComments(argv.Proto)
|
||||||
time.Sleep(5 * time.Second)
|
// time.Sleep(5 * time.Second)
|
||||||
protoReformat(argv.Proto)
|
protoReformat(argv.Proto)
|
||||||
|
log.Info("format done")
|
||||||
okExit("")
|
okExit("")
|
||||||
}
|
}
|
||||||
if argv.Comments {
|
if argv.Comments {
|
||||||
|
|
|
@ -127,29 +127,16 @@ func protoReformat(filename string) error {
|
||||||
|
|
||||||
if strings.HasPrefix(line, "oneof ") {
|
if strings.HasPrefix(line, "oneof ") {
|
||||||
newmsg := basemsg.newOneofMessage(line)
|
newmsg := basemsg.newOneofMessage(line)
|
||||||
newmsg.msgPB.Notes = strings.Split(comments, "\n")
|
newmsg.Notes = strings.Split(comments, "\n")
|
||||||
newmsg.load()
|
newmsg.load()
|
||||||
basemsg.Msgs = append(basemsg.Msgs, newmsg.msgPB)
|
|
||||||
/*
|
|
||||||
for _, newline := range newmsg.msgPB.format() {
|
|
||||||
newfile += fmt.Sprintln(newline)
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
inMessage = true
|
inMessage = true
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if strings.HasPrefix(line, "enum ") {
|
if strings.HasPrefix(line, "enum ") {
|
||||||
newmsg := basemsg.newEnumMessage(line)
|
newmsg := basemsg.newEnumMessage(line)
|
||||||
newmsg.msgPB.Notes = strings.Split(comments, "\n")
|
newmsg.Notes = strings.Split(comments, "\n")
|
||||||
newmsg.load()
|
newmsg.load()
|
||||||
basemsg.Msgs = append(basemsg.Msgs, newmsg.msgPB)
|
|
||||||
// loadEnumDefinition(newmsg)
|
|
||||||
/*
|
|
||||||
for _, newline := range newmsg.msgPB.format() {
|
|
||||||
newfile += fmt.Sprintln(newline)
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
inMessage = true
|
inMessage = true
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
@ -158,14 +145,8 @@ func protoReformat(filename string) error {
|
||||||
log.Info("got to message", line)
|
log.Info("got to message", line)
|
||||||
|
|
||||||
newmsg := basemsg.newStdMessage(line)
|
newmsg := basemsg.newStdMessage(line)
|
||||||
newmsg.msgPB.Notes = strings.Split(comments, "\n")
|
newmsg.Notes = strings.Split(comments, "\n")
|
||||||
newmsg.load()
|
newmsg.load()
|
||||||
basemsg.Msgs = append(basemsg.Msgs, newmsg.msgPB)
|
|
||||||
/*
|
|
||||||
for _, newline := range newmsg.msgPB.format() {
|
|
||||||
newfile += fmt.Sprintln(newline)
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
inMessage = true
|
inMessage = true
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
@ -209,37 +190,28 @@ func newDepth(fmtmsg *FormatMsg, header string) *FormatMsg {
|
||||||
}
|
}
|
||||||
|
|
||||||
// func newStdMessage(fmtmsg *FormatMsg, header string) *StdMessage {
|
// func newStdMessage(fmtmsg *FormatMsg, header string) *StdMessage {
|
||||||
func (msgPB *FormatMsg) newStdMessage(header string) *StdMessage {
|
func (msgPB *FormatMsg) newStdMessage(header string) *FormatMsg {
|
||||||
newmsg := newDepth(msgPB, header)
|
newmsg := newDepth(msgPB, header)
|
||||||
newmsg.Type = FormatMsg_MESSAGE
|
newmsg.Type = FormatMsg_MESSAGE
|
||||||
msgPB.Msgs = append(msgPB.Msgs, newmsg)
|
msgPB.Msgs = append(msgPB.Msgs, newmsg)
|
||||||
|
|
||||||
newstd := new(StdMessage)
|
return newmsg
|
||||||
newstd.msgPB = newmsg
|
|
||||||
|
|
||||||
return newstd
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (msgPB *FormatMsg) newOneofMessage(header string) *StdMessage {
|
func (msgPB *FormatMsg) newOneofMessage(header string) *FormatMsg {
|
||||||
newmsg := newDepth(msgPB, header)
|
newmsg := newDepth(msgPB, header)
|
||||||
newmsg.Type = FormatMsg_ONEOF
|
newmsg.Type = FormatMsg_ONEOF
|
||||||
msgPB.Msgs = append(msgPB.Msgs, newmsg)
|
msgPB.Msgs = append(msgPB.Msgs, newmsg)
|
||||||
|
|
||||||
newstd := new(StdMessage)
|
return newmsg
|
||||||
newstd.msgPB = newmsg
|
|
||||||
|
|
||||||
return newstd
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (msgPB *FormatMsg) newEnumMessage(header string) *EnumMessage {
|
func (msgPB *FormatMsg) newEnumMessage(header string) *FormatMsg {
|
||||||
newmsg := newDepth(msgPB, header)
|
newmsg := newDepth(msgPB, header)
|
||||||
newmsg.Type = FormatMsg_ENUM
|
newmsg.Type = FormatMsg_ENUM
|
||||||
msgPB.Msgs = append(msgPB.Msgs, newmsg)
|
msgPB.Msgs = append(msgPB.Msgs, newmsg)
|
||||||
|
|
||||||
newstd := new(EnumMessage)
|
return newmsg
|
||||||
newstd.msgPB = newmsg
|
|
||||||
|
|
||||||
return newstd
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// proto files can be defined as trees
|
// proto files can be defined as trees
|
||||||
|
@ -247,36 +219,34 @@ func (msgPB *FormatMsg) newEnumMessage(header string) *EnumMessage {
|
||||||
// func (newMsg *EnumMessage) load() {
|
// func (newMsg *EnumMessage) load() {
|
||||||
// func (msg *StdMessage) loadMsgDefinition(msg *StdMessage) {
|
// func (msg *StdMessage) loadMsgDefinition(msg *StdMessage) {
|
||||||
func (msg *StdMessage) load() {
|
func (msg *StdMessage) load() {
|
||||||
|
msg.msgPB.load()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (msg *FormatMsg) load() {
|
||||||
// fmtmsg := msg.msgPB
|
// fmtmsg := msg.msgPB
|
||||||
curPB := msg.msgPB
|
|
||||||
for allTheLines.Scan() {
|
for allTheLines.Scan() {
|
||||||
line := allTheLines.Next()
|
line := allTheLines.Next()
|
||||||
if strings.HasPrefix(line, "oneof ") {
|
if strings.HasPrefix(line, "oneof ") {
|
||||||
newmsg := msg.msgPB.newOneofMessage(line)
|
newmsg := msg.newOneofMessage(line)
|
||||||
newmsg.load()
|
newmsg.load()
|
||||||
// curPB = newmsg.msgPB
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if strings.HasPrefix(line, "enum ") {
|
if strings.HasPrefix(line, "enum ") {
|
||||||
newmsg := msg.msgPB.newEnumMessage(line)
|
newmsg := msg.newEnumMessage(line)
|
||||||
newmsg.load()
|
newmsg.load()
|
||||||
// curPB = newmsg.msgPB
|
|
||||||
// loadEnumDefinition(newmsg)
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if strings.HasPrefix(line, "message ") {
|
if strings.HasPrefix(line, "message ") {
|
||||||
// message inception. search for the architect. don't forget your totem
|
// message inception. search for the architect. don't forget your totem
|
||||||
newmsg := msg.msgPB.newStdMessage(line)
|
newmsg := msg.newStdMessage(line)
|
||||||
newmsg.load()
|
newmsg.load()
|
||||||
// curPB = newmsg.msgPB
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if strings.HasPrefix(line, "}") {
|
if strings.HasPrefix(line, "}") {
|
||||||
msg.msgPB.Footer = line
|
msg.Footer = line
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
curPB.Lines = append(curPB.Lines, line)
|
msg.Lines = append(msg.Lines, line)
|
||||||
// fmtmsg.Lines = append(fmtmsg.Lines, line)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
|
@ -425,8 +395,10 @@ func formatMessage(curmsg *FormatMsg) []string {
|
||||||
}
|
}
|
||||||
newmsg = append(newmsg, line) // " //header")
|
newmsg = append(newmsg, line) // " //header")
|
||||||
} else {
|
} else {
|
||||||
|
if curmsg.Depth != 0 {
|
||||||
newmsg = append(newmsg, "// ERROR: header was blank") // +" //header")
|
newmsg = append(newmsg, "// ERROR: header was blank") // +" //header")
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// find the max length of varname and vartype
|
// find the max length of varname and vartype
|
||||||
setMaxSizes(curmsg)
|
setMaxSizes(curmsg)
|
||||||
|
|
Loading…
Reference in New Issue