rename argv

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-11-05 07:48:22 -06:00
parent f1fbbb3c19
commit d2ba12e6f5
5 changed files with 16 additions and 8 deletions

View File

@ -10,7 +10,9 @@ build:
@# copy the toolkits into the binary during debugging @# copy the toolkits into the binary during debugging
-rm resources/*.so -rm resources/*.so
cp -a ~/go/src/go.wit.com/toolkits/*.so resources/ 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: vet:
GO111MODULE=off go vet GO111MODULE=off go vet

View File

@ -14,7 +14,7 @@ import (
"go.wit.com/log" "go.wit.com/log"
) )
var argv struct { type argv struct {
DownloadAll bool `arg:"--download-all" help:"download everything from go.wit.com"` DownloadAll bool `arg:"--download-all" help:"download everything from go.wit.com"`
GitPull bool `arg:"--git-pull" help:"do git pull in every repository"` 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"` CheckoutUser bool `arg:"--switch-to-user-branch" help:"switch everything to your user branch"`
@ -24,7 +24,7 @@ var argv struct {
} }
func init() { func init() {
arg.MustParse(&argv) arg.MustParse(&myargv)
if debugger.ArgDebug() { if debugger.ArgDebug() {
log.Info("cmd line --debugger == true") 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 // 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. // If any of them are called, don't show the GUI at all and just exit.
func handleCmdLine() { func handleCmdLine() {
var doExit bool = false var doExit bool = false
if argv.CheckoutDevel { if myargv.CheckoutDevel {
me.autotypistWindow.Hide() me.autotypistWindow.Hide()
me.repos.View.ArgCheckoutDevel() me.repos.View.ArgCheckoutDevel()
doExit = true doExit = true
@ -56,7 +60,7 @@ func handleCmdLine() {
log.Info("not switching to devel branches") log.Info("not switching to devel branches")
} }
if argv.CheckoutUser { if myargv.CheckoutUser {
me.autotypistWindow.Hide() me.autotypistWindow.Hide()
me.repos.View.ArgCheckoutUser() me.repos.View.ArgCheckoutUser()
doExit = true doExit = true
@ -64,7 +68,7 @@ func handleCmdLine() {
log.Info("not switching to user branches") log.Info("not switching to user branches")
} }
if argv.GitPull { if myargv.GitPull {
me.autotypistWindow.Hide() me.autotypistWindow.Hide()
if me.repos.View.ArgGitPull() { if me.repos.View.ArgGitPull() {
log.Info("git pull everywhere worked") log.Info("git pull everywhere worked")

View File

@ -235,7 +235,7 @@ func writeFile(w http.ResponseWriter, filename string) {
func startHTTP() { func startHTTP() {
http.HandleFunc("/", okHandler) http.HandleFunc("/", okHandler)
p := fmt.Sprintf(":%d", argv.Port) p := fmt.Sprintf(":%d", myargv.Port)
log.Println("Running on port", p) log.Println("Running on port", p)
err := http.ListenAndServe(p, nil) err := http.ListenAndServe(p, nil)

View File

@ -12,7 +12,7 @@ import (
func (r *repoWindow) initRepoList() { func (r *repoWindow) initRepoList() {
r.View.InitRepoList(".config/autotypist") r.View.InitRepoList(".config/autotypist")
if argv.OnlyMe { if myargv.OnlyMe {
log.Info("not scanning everything") log.Info("not scanning everything")
} else { } else {
log.Info("scanning everything in ~/go/src") log.Info("scanning everything in ~/go/src")

View File

@ -8,8 +8,10 @@ import (
"go.wit.com/gui" "go.wit.com/gui"
) )
var VERSION string
//go:embed resources/* //go:embed resources/*
var resources embed.FS var resources embed.FS
var myargv argv
func main() { func main() {
me = new(autoType) me = new(autoType)