diff options
| -rw-r--r-- | argv.go | 41 | ||||
| -rw-r--r-- | main.go | 7 | ||||
| -rw-r--r-- | structs.go | 17 |
3 files changed, 53 insertions, 12 deletions
@@ -1,27 +1,46 @@ 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' */ -import ( - "go.wit.com/dev/alexflint/arg" -) - var argv args type args struct { - ListRepos bool `arg:"--list-repos" help:"list all repositories"` - Port int `arg:"--port" default:"2520" help:"port to run on"` - RepoMap string `arg:"--repomap" default:"/etc/gowebd/repomap" help:"repomap file"` - Hostname string `arg:"--hostname" default:"go.wit.com" help:"hostname to use"` + Test *EmptyCmd `arg:"subcommand:test" help:"test repomap"` + ListRepos bool `arg:"--list-repos" help:"list all repositories"` + Port int `arg:"--port" default:"2520" help:"port to run on"` + RepoMap string `arg:"--repomap" default:"/etc/gowebd/repomap" help:"repomap file"` + Hostname string `arg:"--hostname" default:"go.wit.com" help:"hostname to use"` +} + +type EmptyCmd struct { } func (args) Version() string { - return "gowebd " + VERSION + " Built on " + BUILDTIME + return ARGNAME + " " + VERSION + " Built on " + BUILDTIME +} + +func (args) Buildtime() (string, string) { + return BUILDTIME, VERSION +} + +func (args) Appname() string { + return ARGNAME } -func init() { - arg.MustParse(&argv) +func (a args) DoAutoComplete(pb *prep.Auto) { + if pb.Cmd == "" { + pb.Autocomplete3([]string{"test", "--version", "--force"}) + } else { + pb.SubCommand(pb.Goargs...) + } + os.Exit(0) } @@ -6,6 +6,7 @@ import ( "net/http" "time" + "go.wit.com/lib/gui/prep" "go.wit.com/lib/protobuf/forgepb" "go.wit.com/lib/protobuf/gitpb" "go.wit.com/log" @@ -18,7 +19,8 @@ var BUILDTIME string //go:embed resources/* var resources embed.FS -// var accessf, clientf *os.File +// used for shell auto completion +var ARGNAME string = "gowebd" var repoMap map[string]string var gitMap map[string]*gitpb.Repo @@ -32,6 +34,9 @@ var FOOTER string = "/etc/gowebd/footer.html" var LIBDIR string = "/var/lib/gowebd/" func main() { + me = new(mainType) + me.sh = prep.Bash(&argv) // adds shell auto complete to go-args + if argv.RepoMap != "" { REPOMAP = argv.RepoMap } diff --git a/structs.go b/structs.go new file mode 100644 index 0000000..af1e4a1 --- /dev/null +++ b/structs.go @@ -0,0 +1,17 @@ +// Copyright 2017-2025 WIT.COM Inc. All rights reserved. +// Use of this source code is governed by the GPL 3.0 + +package main + +import ( + "go.wit.com/lib/gui/prep" + "go.wit.com/lib/protobuf/forgepb" +) + +var me *mainType + +// this app's variables +type mainType struct { + sh *prep.Auto // shell autocomplete + forge *forgepb.Forge // for holding the forge protobuf files +} |
