summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rw-r--r--argv.go23
-rwxr-xr-xbuild4
-rw-r--r--generateMarshal.go4
-rw-r--r--main.go8
5 files changed, 33 insertions, 8 deletions
diff --git a/Makefile b/Makefile
index 5b37cf5..3931172 100644
--- a/Makefile
+++ b/Makefile
@@ -39,7 +39,7 @@ recover:
make goimports
make build
-build:
+build: goimports vet
GO111MODULE=off go build \
-ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}"
# autogen uses autogen to build. keep a working copy somewhere
diff --git a/argv.go b/argv.go
index 0cb2c9b..8542fe5 100644
--- a/argv.go
+++ b/argv.go
@@ -3,6 +3,12 @@
package main
+import (
+ "os"
+
+ "go.wit.com/lib/gui/prep"
+)
+
/*
this parses the command line arguements
@@ -48,3 +54,20 @@ Example usage:
func (args) Version() string {
return "go.wit.com/apps/autogenpb " + VERSION + " Built on " + BUILDTIME
}
+
+/*
+ handles shell autocomplete
+*/
+
+func (args) Appname() string {
+ return ARGNAME
+}
+
+func (a args) DoAutoComplete(pb *prep.Auto) {
+ if pb.Cmd == "" {
+ pb.Autocomplete3([]string{"--bash", "--proto", "--regret", "--debug", "--delete", "--dry-run"})
+ } else {
+ pb.SubCommand(pb.Argv...)
+ }
+ os.Exit(0)
+}
diff --git a/build b/build
new file mode 100755
index 0000000..1719218
--- /dev/null
+++ b/build
@@ -0,0 +1,4 @@
+#!/bin/bash -x
+
+mkdir -p files/usr/share/bash-completion/completions/
+autogenpb --bash > files/usr/share/bash-completion/completions/autogenpb
diff --git a/generateMarshal.go b/generateMarshal.go
index 39929eb..0c58959 100644
--- a/generateMarshal.go
+++ b/generateMarshal.go
@@ -11,10 +11,6 @@ import (
// makes Marshal and Unmarshal functions for protoWIRE protoTEXT and protoJSON
func (pb *Files) marshal(f *File) {
- if argv.DryRun {
- return
- }
-
w, _ := os.OpenFile(f.Filebase+".marshal.pb.go", os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644)
headerComment(w)
diff --git a/main.go b/main.go
index e879de4..ba72ece 100644
--- a/main.go
+++ b/main.go
@@ -20,8 +20,8 @@ import (
"strings"
"github.com/go-cmd/cmd"
- "go.wit.com/dev/alexflint/arg"
"go.wit.com/lib/fhelp"
+ "go.wit.com/lib/gui/prep"
"go.wit.com/lib/gui/shell"
"go.wit.com/log"
)
@@ -30,10 +30,12 @@ import (
var VERSION string
var BUILDTIME string
+var ARGNAME string = "autogenpb"
+
// var fsort *os.File // the sort.pb.go output file
func main() {
- pp := arg.MustParse(&argv)
+ auto := prep.Bash3(&argv) // add support for bash autocomplete with go-arg
var pb *Files
pb = new(Files)
@@ -48,7 +50,7 @@ func main() {
// you need a proto file
if argv.Proto == "" {
log.Info("you must provide --proto <filename>")
- pp.WriteHelp(os.Stdout)
+ auto.WriteHelp()
os.Exit(-1)
}