57 lines
1.9 KiB
Go
57 lines
1.9 KiB
Go
package main
|
|
|
|
/*
|
|
this parses the command line arguements
|
|
|
|
this enables command line options from other packages like 'gui' and 'log'
|
|
*/
|
|
|
|
var argv args
|
|
|
|
type args struct {
|
|
LoBase string `arg:"--lobase" help:"lowercase basename"`
|
|
UpBase string `arg:"--upbase" help:"uppercase basename"`
|
|
Proto string `arg:"--proto" help:"the .proto filename"`
|
|
Append string `arg:"--append" help:"will keep this key unique on append"`
|
|
Sort []string `arg:"-s,--sort,separate" help:"how and what to sort on"`
|
|
Marshal []string `arg:"--marshal" help:"what to marshal on"`
|
|
NoMarshal bool `arg:"--no-marshal" help:"do not make a marshal.pb.go file"`
|
|
NoSort bool `arg:"--no-sort" help:"do not make a sort.pb.go file"`
|
|
Mutex bool `arg:"--mutex" help:"try mutex hack (breaks proto.Marshal()"`
|
|
DryRun bool `arg:"--dry-run" help:"show what would be run"`
|
|
GoSrc string `arg:"--go-src" help:"default is ~/go/src. could be set to your go.work path"`
|
|
GoPath string `arg:"--gopath" help:"the gopath of this repo"`
|
|
}
|
|
|
|
func (a args) Description() string {
|
|
return `
|
|
autogenpb tries to generate a sort.pb.go file for a protobuf
|
|
|
|
Install with:
|
|
|
|
go install go.wit.com/apps/autogenpb@latest
|
|
|
|
More information at:
|
|
|
|
https://go.wit.com/
|
|
|
|
The protobuf is assumed to have a 'standard' format.
|
|
|
|
That is the .proto file:
|
|
|
|
* only defines one thing and it's the same name as the file
|
|
* uses the concept of 'plural' (like ruby on rails)
|
|
This means, the file should be "apples.proto" and inside
|
|
have 'message Apple' and 'message Apples'
|
|
The "message Apples" should have a repeated Apple apples
|
|
|
|
There is an example in the code:
|
|
|
|
go-clone go.wit.com/apps/autogenpb
|
|
`
|
|
}
|
|
|
|
func (args) Version() string {
|
|
return "go-clone " + VERSION + " Built on " + BUILDTIME
|
|
}
|