only sort keys left
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
8158a66db5
commit
ba981d6bb2
5
argv.go
5
argv.go
|
@ -9,8 +9,9 @@ package main
|
||||||
var argv args
|
var argv args
|
||||||
|
|
||||||
type args struct {
|
type args struct {
|
||||||
Base string `arg:"--base" help:"basename"`
|
LoBase string `arg:"--lobase" help:"lowercase basename"`
|
||||||
Proto string `arg:"--proto" help:"the .proto filename"`
|
UpBase string `arg:"--upbase" help:"uppercase basename"`
|
||||||
|
Proto string `arg:"--proto" help:"the .proto filename"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a args) Description() string {
|
func (a args) Description() string {
|
||||||
|
|
20
main.go
20
main.go
|
@ -18,12 +18,6 @@ var BUILDTIME string
|
||||||
func main() {
|
func main() {
|
||||||
pp := arg.MustParse(&argv)
|
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
|
// you need a proto file
|
||||||
if argv.Proto == "" {
|
if argv.Proto == "" {
|
||||||
log.Info("you must provide --proto <filename>")
|
log.Info("you must provide --proto <filename>")
|
||||||
|
@ -35,11 +29,17 @@ func main() {
|
||||||
os.Exit(-1)
|
os.Exit(-1)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ! strings.HasSuffix(argv.Proto, ".proto") {
|
if !strings.HasSuffix(argv.Proto, ".proto") {
|
||||||
log.Info("protobuf", argv.Proto, "must end in .proto")
|
log.Info("protobuf", argv.Proto, "must end in .proto")
|
||||||
os.Exit(-1)
|
os.Exit(-1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// you need --upbase and --lobase
|
||||||
|
if argv.UpBase == "" {
|
||||||
|
pp.WriteHelp(os.Stdout)
|
||||||
|
os.Exit(-1)
|
||||||
|
}
|
||||||
|
|
||||||
cmd := []string{"go", "list", "-f", "'{{.Name}}'"}
|
cmd := []string{"go", "list", "-f", "'{{.Name}}'"}
|
||||||
result := shell.Run(cmd)
|
result := shell.Run(cmd)
|
||||||
|
|
||||||
|
@ -50,13 +50,13 @@ func main() {
|
||||||
|
|
||||||
protobase := strings.TrimSuffix(argv.Proto, ".proto")
|
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 := make(map[string]string)
|
||||||
sortmap["package"] = packageName
|
sortmap["package"] = packageName
|
||||||
sortmap["base"] = "gitTag"
|
sortmap["base"] = argv.LoBase
|
||||||
sortmap["lock"] = sortmap["base"] + "slock"
|
sortmap["lock"] = sortmap["base"] + "slock"
|
||||||
sortmap["Base"] = "GitTag"
|
sortmap["Base"] = argv.UpBase
|
||||||
sortmap["Bases"] = sortmap["Base"] + "s"
|
sortmap["Bases"] = sortmap["Base"] + "s"
|
||||||
|
|
||||||
sortmap["sortBy"] = "ByPath"
|
sortmap["sortBy"] = "ByPath"
|
||||||
|
|
|
@ -6,7 +6,7 @@ test: vet
|
||||||
all: clean test.pb.go run goimports vet
|
all: clean test.pb.go run goimports vet
|
||||||
|
|
||||||
run:
|
run:
|
||||||
../autogenpb --proto test.proto
|
../autogenpb --proto test.proto --lobase gitTag --upbase GitTag
|
||||||
|
|
||||||
vet:
|
vet:
|
||||||
@GO111MODULE=off go vet
|
@GO111MODULE=off go vet
|
||||||
|
|
Loading…
Reference in New Issue