summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--args.go12
-rw-r--r--globalResetOptions.go3
-rw-r--r--handleCmdLine.go122
-rw-r--r--main.go3
4 files changed, 134 insertions, 6 deletions
diff --git a/args.go b/args.go
index 0f45f70..0711ba4 100644
--- a/args.go
+++ b/args.go
@@ -12,11 +12,15 @@ import (
"go.wit.com/log"
)
- // GadgetDisplay string `arg:"env:DISPLAY"`
- // GadgetTmpLog bool `arg:"--tmp-log" help:"automatically send STDOUT to /tmp"`
- // GadgetVerboseDNS bool `arg:"--verbose" help:"debug your dns settings"`
+// GadgetDisplay string `arg:"env:DISPLAY"`
+// GadgetTmpLog bool `arg:"--tmp-log" help:"automatically send STDOUT to /tmp"`
+// GadgetVerboseDNS bool `arg:"--verbose" help:"debug your dns settings"`
var args struct {
- TmpLog bool `arg:"--tmp-log" help:"automatically send STDOUT to /tmp"`
+ 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"`
+ CheckoutDevel bool `arg:"--switch-to-devel-branch" help:"switch everything to the devel branch"`
+ TmpLog bool `arg:"--tmp-log" help:"automatically send STDOUT to /tmp"`
}
func init() {
diff --git a/globalResetOptions.go b/globalResetOptions.go
index 5f7f347..bab1934 100644
--- a/globalResetOptions.go
+++ b/globalResetOptions.go
@@ -25,7 +25,6 @@ func globalResetOptions(box *gui.Node) {
me.autoDryRun = group2.NewCheckbox("autotypist --dry-run")
me.autoDryRun.SetChecked(true)
-
buildOptions := group2.NewGrid("buildOptions", 2, 1)
buildOptions.NewLabel("start over")
@@ -56,7 +55,7 @@ func globalResetOptions(box *gui.Node) {
func attemptAutoRebuild() {
os.Setenv("GO111MODULE", "off")
- version := "v0.19.1"
+ version := "latest"
homeDir := me.userHomePwd.String()
quickCmd(homeDir, []string{"mkdir", "-p", "go/src/go.wit.com/apps/"})
diff --git a/handleCmdLine.go b/handleCmdLine.go
new file mode 100644
index 0000000..e49be8d
--- /dev/null
+++ b/handleCmdLine.go
@@ -0,0 +1,122 @@
+package main
+
+import (
+ "os"
+
+ "go.wit.com/log"
+)
+
+/*
+This will process the command line arguements like --git-pull
+
+It should do them in a smart order. If any of them are called,
+don't show the GUI at all and just exit.
+*/
+
+func argGitPull() bool {
+ log.Info("running git pull everywhere")
+ me.autotypistWindow.Hide()
+ cmd := []string{"git", "pull"}
+ var failed int = 0
+ for _, repo := range me.allrepos {
+ log.Info("Running:", repo.String(), cmd)
+ err, output := repo.status.RunCmd(cmd)
+ if err == nil {
+ log.Info(output)
+ } else {
+ failed += 1
+ log.Info("Something went wrong. Got err", err)
+ log.Info("output =", output)
+ return false
+ }
+ }
+ log.Info("Ran git pull in all repos. failure count =", failed)
+ return true
+}
+
+func argCheckoutDevel() bool {
+ log.Info("running git checkout devel everwhere")
+ me.autotypistWindow.Hide()
+ var failed int = 0
+ for _, repo := range me.allrepos {
+ if repo.status.CheckDirty() {
+ log.Info("skipping dirty repo", repo.String())
+ continue
+ }
+ branch := repo.status.GetDevelBranchName()
+ cmd := []string{"git", "checkout", branch}
+ log.Info("Running:", cmd, "in", repo.String())
+ err, output := repo.status.RunCmd(cmd)
+ if err == nil {
+ log.Info("git checkout worked", output)
+ } else {
+ failed += 1
+ log.Info("git checkout failed")
+ log.Info("Something went wrong. Got err", err)
+ log.Info("output =", output)
+ // return false
+ }
+ }
+ log.Info("Ran git checkout in all repos. failure count =", failed)
+ return true
+}
+
+func argCheckoutUser() bool {
+ log.Info("running git checkout devel everwhere")
+ me.autotypistWindow.Hide()
+ var failed int = 0
+ for _, repo := range me.allrepos {
+ if repo.status.CheckDirty() {
+ log.Info("skipping dirty repo", repo.String())
+ continue
+ }
+ branch := repo.status.GetUserBranchName()
+ cmd := []string{"git", "checkout", branch}
+ log.Info("Running:", cmd, "in", repo.String())
+ err, output := repo.status.RunCmd(cmd)
+ if err == nil {
+ log.Info("git checkout worked", output)
+ } else {
+ failed += 1
+ log.Info("git checkout failed")
+ log.Info("Something went wrong. Got err", err)
+ log.Info("output =", output)
+ // return false
+ }
+ }
+ log.Info("Ran git checkout in all repos. failure count =", failed)
+ return true
+}
+
+func handleCmdLine() {
+ var doExit bool = false
+
+ if args.CheckoutDevel {
+ argCheckoutDevel()
+ doExit = true
+ } else {
+ log.Info("not switching to devel branches")
+ }
+
+ if args.CheckoutUser {
+ argCheckoutUser()
+ doExit = true
+ } else {
+ log.Info("not switching to user branches")
+ }
+
+ if args.GitPull {
+ if argGitPull() {
+ log.Info("git pull everywhere worked")
+ } else {
+ log.Info("git failed somewhere")
+ }
+ doExit = true
+ } else {
+ log.Info("not running git pull everywhere")
+ }
+
+ if doExit {
+ os.Exit(0)
+ }
+}
diff --git a/main.go b/main.go
index 753013d..7016d47 100644
--- a/main.go
+++ b/main.go
@@ -30,6 +30,9 @@ func main() {
autotypistWindow()
repolistWindow()
+ // process everything on the command line
+ handleCmdLine()
+
for _, repo := range me.allrepos {
repo.status.Update()
repo.newScan()