only sort keys left

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-11-29 11:21:56 -06:00
parent 8158a66db5
commit ba981d6bb2
3 changed files with 14 additions and 13 deletions

View File

@ -9,7 +9,8 @@ package main
var argv args
type args struct {
Base string `arg:"--base" help:"basename"`
LoBase string `arg:"--lobase" help:"lowercase basename"`
UpBase string `arg:"--upbase" help:"uppercase basename"`
Proto string `arg:"--proto" help:"the .proto filename"`
}

20
main.go
View File

@ -18,12 +18,6 @@ var BUILDTIME string
func main() {
pp := arg.MustParse(&argv)
// for very new users or users unfamilar with the command line, this may help them
if argv.Base == "help" || argv.Base == "?" {
pp.WriteHelp(os.Stdout)
os.Exit(-1)
}
// you need a proto file
if argv.Proto == "" {
log.Info("you must provide --proto <filename>")
@ -35,11 +29,17 @@ func main() {
os.Exit(-1)
}
if ! strings.HasSuffix(argv.Proto, ".proto") {
if !strings.HasSuffix(argv.Proto, ".proto") {
log.Info("protobuf", argv.Proto, "must end in .proto")
os.Exit(-1)
}
// you need --upbase and --lobase
if argv.UpBase == "" {
pp.WriteHelp(os.Stdout)
os.Exit(-1)
}
cmd := []string{"go", "list", "-f", "'{{.Name}}'"}
result := shell.Run(cmd)
@ -50,13 +50,13 @@ func main() {
protobase := strings.TrimSuffix(argv.Proto, ".proto")
f, _ := os.OpenFile(protobase + ".sort.pb.go", os.O_WRONLY|os.O_CREATE, 0600)
f, _ := os.OpenFile(protobase+".sort.pb.go", os.O_WRONLY|os.O_CREATE, 0600)
sortmap := make(map[string]string)
sortmap["package"] = packageName
sortmap["base"] = "gitTag"
sortmap["base"] = argv.LoBase
sortmap["lock"] = sortmap["base"] + "slock"
sortmap["Base"] = "GitTag"
sortmap["Base"] = argv.UpBase
sortmap["Bases"] = sortmap["Base"] + "s"
sortmap["sortBy"] = "ByPath"

View File

@ -6,7 +6,7 @@ test: vet
all: clean test.pb.go run goimports vet
run:
../autogenpb --proto test.proto
../autogenpb --proto test.proto --lobase gitTag --upbase GitTag
vet:
@GO111MODULE=off go vet