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
-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

View File

@ -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")

View File

@ -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)

View File

@ -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")

View File

@ -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)