summaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'main.go')
-rw-r--r--main.go67
1 files changed, 41 insertions, 26 deletions
diff --git a/main.go b/main.go
index 3de4d3b..5f2ccf7 100644
--- a/main.go
+++ b/main.go
@@ -39,6 +39,19 @@ func getVersion(repo *gitpb.Repo, name string) string {
return strings.TrimSpace(output)
}
+func showUrls() bool {
+ if argv.Show == nil {
+ return false
+ }
+ if argv.Show.Repo == nil {
+ return false
+ }
+ if argv.Show.Repo.Urls != nil {
+ return true
+ }
+ return false
+}
+
func main() {
me = new(mainType)
@@ -56,6 +69,18 @@ func main() {
dumpDebug()
}
+ if me.sh.Cmd == "" {
+ s, err := doDefaultBehavior()
+ if err != nil {
+ me.sh.BadExit(s, err)
+ }
+ me.sh.GoodExit(s)
+ }
+
+ //// start standard argv subcommand processing here ////
+
+ var s string
+ var err error
if argv.Dev != nil {
// first find the repos or gopaths to operate on
if argv.Dev.Config != nil {
@@ -172,10 +197,7 @@ func main() {
}
if argv.Patch != nil {
- if err := doPatch(); err != nil {
- badExit(err)
- }
- okExit("")
+ s, err = doPatch()
}
// open the gui unless the user performed some other
@@ -190,42 +212,35 @@ func main() {
debug() // sits here forever
}
+ if err != nil {
+ me.sh.BadExit(s, err)
+ }
+ me.sh.GoodExit(s)
+}
+
+func doDefaultBehavior() (string, error) {
// DEFAULT BEHAVIOR CHANGES BETWEEN MODES
if me.forge.Config.Mode == forgepb.ForgeMode_NORMAL || me.forge.Config.Mode == forgepb.ForgeMode_USER {
// PROBABLY YOU ARE WRITING CODE
// got to the end with nothing to do (?)
if showWorkRepos() {
// found some repos at least
- } else {
- // every repo is in a really clean state. no extra files anywhere
- // no dirty repos, no repos that need to be published
- // nothing different between user and master branch version. not common
- log.Info("All of your git repositories appear to be in perfect shape")
}
- okExit("")
+ // every repo is in a really clean state. no extra files anywhere
+ // no dirty repos, no repos that need to be published
+ // nothing different between user and master branch version. not common
+ s := "All of your git repositories appear to be in perfect shape"
+ return s, nil
}
if me.forge.Config.Mode == forgepb.ForgeMode_MASTER {
// PROBABLY YOU ARE PUBLISHING / MERGING CODE
defaultBehaviorMaster()
- okExit("")
+ return "default master behavior", nil
}
// PROBABLY A NEW USER
found := findAll()
- me.forge.PrintDefaultTB(found)
- okExit("")
-}
-
-func showUrls() bool {
- if argv.Show == nil {
- return false
- }
- if argv.Show.Repo == nil {
- return false
- }
- if argv.Show.Repo.Urls != nil {
- return true
- }
- return false
+ footer := me.forge.PrintDefaultTB(found)
+ return footer, nil
}