blob: 237f1b014fa0f3536635323809c867a60bc3bc05 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
// Copyright 2017-2025 WIT.COM Inc. All rights reserved.
// Use of this source code is governed by the GPL 3.0
package main
import (
"os"
"go.wit.com/lib/gui/prep"
)
/*
this parses the command line arguements
this enables command line options from other packages like 'gui' and 'log'
*/
var argv args
type args struct {
Package string `arg:"--package" help:"the package name"`
Proto string `arg:"--proto" help:"the .proto filename"`
Mutex bool `arg:"--mutex" default:"true" help:"insert a mutex into protoc .pb.go file"`
MutexName string `arg:"--mutex-name" help:"use a var name for the mutex"`
Regret bool `arg:"--regret" help:"ignore needed UUID. You will eventually regret this."`
Delete bool `arg:"--delete" help:"use delete with copy experiment"`
DryRun bool `arg:"--dry-run" help:"check the .proto syntax, but don't do anything"`
Format bool `arg:"--format" help:"format the .proto file and exit"`
Debug bool `arg:"--debug" help:"enable debugging information"`
Comments bool `arg:"--format-comments" help:"enforce parseable comments in a .proto file"`
NoFormat bool `arg:"--no-format" help:"do not auto-reformat the .proto file"`
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"`
Identify string `arg:"--identify" help:"identify file"`
}
func (a args) Description() string {
return "go.wit.com/apps/autogenpb " + VERSION + " Built on " + BUILDTIME + `
From a .proto file, autogenpb will:
* auto generate Sort(), Marshal() and GUI() functions in .pb.go files
* auto format the .proto file (like goimport does for .go files)
* encourages (enforces?) plural struct names (like rails)
See the sources for an example .proto files
Example usage:
autogenpb --proto foo.proto --package main
`
}
func (args) Version() string {
return "go.wit.com/apps/autogenpb " + VERSION + " Built on " + BUILDTIME
}
/*
handles shell autocomplete
*/
func (args) Appname() string {
return ARGNAME
}
func (args) Buildtime() (string, string) {
return BUILDTIME, VERSION
}
func (a args) DoAutoComplete(pb *prep.Auto) {
if pb.Cmd == "" {
pb.Autocomplete3([]string{"--bash", "--proto", "--regret", "--debug", "--delete", "--dry-run", "--version"})
} else {
pb.SubCommand(pb.Goargs...)
}
os.Exit(0)
}
|