diff --git a/Makefile b/Makefile index a42023b..87a1be3 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,9 @@ build: @# copy the toolkits into the binary during debugging -rm resources/*.so cp -a ~/go/src/go.wit.com/toolkits/*.so resources/ - GO111MODULE=off go build -v -x + GO111MODULE=off go build -v -x \ + -ldflags " \ + -X main.VERSION=${VERSION}" vet: GO111MODULE=off go vet diff --git a/args.go b/argv.go similarity index 91% rename from args.go rename to argv.go index 5515f88..05e5e23 100644 --- a/args.go +++ b/argv.go @@ -14,7 +14,7 @@ import ( "go.wit.com/log" ) -var argv struct { +type argv struct { DownloadAll bool `arg:"--download-all" help:"download everything from go.wit.com"` GitPull bool `arg:"--git-pull" help:"do git pull in every repository"` CheckoutUser bool `arg:"--switch-to-user-branch" help:"switch everything to your user branch"` @@ -24,7 +24,7 @@ var argv struct { } func init() { - arg.MustParse(&argv) + arg.MustParse(&myargv) if debugger.ArgDebug() { log.Info("cmd line --debugger == true") @@ -43,12 +43,16 @@ func init() { } } +func (argv) Version() string { + return "autotypist " + VERSION +} + // This will process the command line arguements after everything is initialized // If any of them are called, don't show the GUI at all and just exit. func handleCmdLine() { var doExit bool = false - if argv.CheckoutDevel { + if myargv.CheckoutDevel { me.autotypistWindow.Hide() me.repos.View.ArgCheckoutDevel() doExit = true @@ -56,7 +60,7 @@ func handleCmdLine() { log.Info("not switching to devel branches") } - if argv.CheckoutUser { + if myargv.CheckoutUser { me.autotypistWindow.Hide() me.repos.View.ArgCheckoutUser() doExit = true @@ -64,7 +68,7 @@ func handleCmdLine() { log.Info("not switching to user branches") } - if argv.GitPull { + if myargv.GitPull { me.autotypistWindow.Hide() if me.repos.View.ArgGitPull() { log.Info("git pull everywhere worked") diff --git a/http.go b/http.go index 6d64a0c..cfa26af 100644 --- a/http.go +++ b/http.go @@ -235,7 +235,7 @@ func writeFile(w http.ResponseWriter, filename string) { func startHTTP() { http.HandleFunc("/", okHandler) - p := fmt.Sprintf(":%d", argv.Port) + p := fmt.Sprintf(":%d", myargv.Port) log.Println("Running on port", p) err := http.ListenAndServe(p, nil) diff --git a/initRepoList.go b/initRepoList.go index 7f71719..322ee5c 100644 --- a/initRepoList.go +++ b/initRepoList.go @@ -12,7 +12,7 @@ import ( func (r *repoWindow) initRepoList() { r.View.InitRepoList(".config/autotypist") - if argv.OnlyMe { + if myargv.OnlyMe { log.Info("not scanning everything") } else { log.Info("scanning everything in ~/go/src") diff --git a/main.go b/main.go index e76fd34..41161e8 100644 --- a/main.go +++ b/main.go @@ -8,8 +8,10 @@ import ( "go.wit.com/gui" ) +var VERSION string //go:embed resources/* var resources embed.FS +var myargv argv func main() { me = new(autoType)