make some help on the correct messages needed
This commit is contained in:
parent
08cd2afd86
commit
721bbd8f92
|
@ -9,8 +9,8 @@ message Bad {
|
|||
string something = 1;
|
||||
}
|
||||
|
||||
message Badthing {
|
||||
message Badss {
|
||||
string uuid = 1; // `autogenpb:uuid:be926ad9-f07f-484c-adf2-d96eeabf3079`
|
||||
string version = 2; // `autogenpb:version:v0.0.1`
|
||||
repeated Bad Bads = 3;
|
||||
string versions = 2; // `autogenpb:version:v0.0.1`
|
||||
repeated Bad Badss = 3;
|
||||
}
|
||||
|
|
|
@ -11,6 +11,8 @@ import (
|
|||
"go.wit.com/log"
|
||||
"golang.org/x/text/cases"
|
||||
"golang.org/x/text/language"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
// this parses the .proto file and handles anything with `autogenpb: `
|
||||
|
@ -34,8 +36,10 @@ func (pb *Files) hasPluralMessage(f *File) error {
|
|||
continue
|
||||
}
|
||||
|
||||
scanner.Scan()
|
||||
line = scanner.Text()
|
||||
fields := strings.Fields(line)
|
||||
// log.Info("GOT LINE", line)
|
||||
if fields[0] == "string" && fields[1] != "uuid" {
|
||||
f.noUuid()
|
||||
return fmt.Errorf("proto file does not have a UUID")
|
||||
|
@ -44,8 +48,10 @@ func (pb *Files) hasPluralMessage(f *File) error {
|
|||
f.Uuid = line
|
||||
log.Info("found UUID:", line)
|
||||
|
||||
scanner.Scan()
|
||||
line = scanner.Text()
|
||||
fields = strings.Fields(line)
|
||||
// log.Info("GOT LINE", line)
|
||||
if fields[0] == "string" && fields[1] != "version" {
|
||||
f.noUuid()
|
||||
return fmt.Errorf("proto file does not have a version")
|
||||
|
@ -85,6 +91,7 @@ func (pf *File) noPluralMessage() {
|
|||
|
||||
func (pf *File) noUuid() {
|
||||
base := cases.Title(language.English, cases.NoLower).String(pf.Filebase)
|
||||
id := uuid.New()
|
||||
|
||||
log.Info("")
|
||||
log.Info("###########################################################################")
|
||||
|
@ -92,10 +99,10 @@ func (pf *File) noUuid() {
|
|||
log.Info("")
|
||||
log.Info("For autogenpb to work on your file", pf.Filename, ",", base+"s must be exactly:")
|
||||
log.Info("")
|
||||
log.Info("message Fruits { // `autogenpb:marshal` `autogenpb:mutex`")
|
||||
log.Info(" string uuid = 1; // `autogenpb:uuid:be926ad9-f07f-484c-adf2-d96eeabf3079`")
|
||||
log.Info("message", base+"s", "{ // `autogenpb:marshal` `autogenpb:mutex`")
|
||||
log.Info(" string uuid = 1; // `autogenpb:uuid:" + id.String() + "`")
|
||||
log.Info(" string version = 2; // `autogenpb:version:v0.0.1`")
|
||||
log.Info(" repeated Fruit Fruits = 3; // THIS MUST BE ", base, " and then ", base+"s")
|
||||
log.Info(" repeated", base, base+"s", " = 3; // THIS MUST BE ", base, " and then ", base+"s")
|
||||
log.Info("}")
|
||||
log.Info("")
|
||||
log.Info("If you don't have a UUID, you can use the randomly generated one here")
|
||||
|
|
Loading…
Reference in New Issue