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