summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-12-27 03:39:53 -0600
committerJeff Carr <[email protected]>2024-12-27 03:39:53 -0600
commit9818e8d1ee685fa11f6ed9745a92e0c31c3a75f1 (patch)
tree9e7d6d47032240eb5a4c4232657cd6bc8d979aa5
parentbdaa40c51fe98ff167d2c05a0b21600c95185e67 (diff)
more ideas for command line options
-rw-r--r--Makefile18
-rw-r--r--argv.go21
-rw-r--r--findRepos.go76
-rw-r--r--main.go41
4 files changed, 103 insertions, 53 deletions
diff --git a/Makefile b/Makefile
index 43735d6..f3eec13 100644
--- a/Makefile
+++ b/Makefile
@@ -41,13 +41,13 @@ fix: install
forge --fix find --all
list-all: install
- forge find --all
+ forge list --all
git-reset: install
forge --do-git-reset find --all
readonly: install
- forge --do-list find --readonly
+ forge --list find --readonly
config: install
forge --config
@@ -56,13 +56,13 @@ scan: install
forge do --scan
pull: install
- forge do --pull
+ forge pull --mine
mine: install
- forge --no-gui find --mine
+ forge list --mine
all: install
- forge --no-gui find --all
+ forge list --all
patches: install
forge --patchset "from makefile"
@@ -82,8 +82,10 @@ restart:
make private
user: install
- forge find --all --user
- forge --no-gui find --all
+ forge user
+
+devel: install
+ forge devel --all
master: install
- forge --master
+ forge master --all
diff --git a/argv.go b/argv.go
index d386dcf..9d15e00 100644
--- a/argv.go
+++ b/argv.go
@@ -16,23 +16,24 @@ type FindCmd struct {
type args struct {
Find *FindCmd `arg:"subcommand:find" help:"select repos (for example, --all or --mine)"`
+ List *FindCmd `arg:"subcommand:list" help:"just show a table of the current state"`
+ User *FindCmd `arg:"subcommand:user" help:"git checkout user"`
+ Devel *FindCmd `arg:"subcommand:devel" help:"git checkout devel"`
+ Master *FindCmd `arg:"subcommand:master" help:"git checkout master"`
+ GitPull *FindCmd `arg:"subcommand:pull" help:"run 'git pull'"`
Config bool `arg:"--config" help:"show your .config/forge/ settings"`
ListPatchSet bool `arg:"--list-patchset" help:"list patch sets"`
DryRun bool `arg:"--dry-run" help:"show what would be run"`
Fix bool `arg:"--fix" help:"fix config, save config & exit"`
Delete string `arg:"--delete" help:"delete this repo"`
- User bool `arg:"--user" help:"git checkout user"`
- Devel bool `arg:"--devel" help:"git checkout devel"`
- Master bool `arg:"--master" help:"git checkout master"`
URL string `arg:"--connect" help:"gowebd url"`
Register string `arg:"--register" help:"register your git URL (foo.com/mystuff) or (github.com/foo/bar)"`
- List bool `arg:"--list" help:"just show a table of the current state"`
- GitPull bool `arg:"--pull" help:"run 'git pull'"`
- GitReset bool `arg:"--git-reset" help:"run 'git reset --hard'"`
- Scan bool `arg:"--scan" help:"reload protobuf from .git/"`
- Force bool `arg:"--force" help:"force redo things"`
- Dirty bool `arg:"--dirty" help:"update git CheckDirty()"`
- PatchSet string `arg:"--patchset" help:"make patch set"`
+ // List bool `arg:"--list" help:"just show a table of the current state"`
+ GitReset bool `arg:"--git-reset" help:"run 'git reset --hard'"`
+ Scan bool `arg:"--scan" help:"reload protobuf from .git/"`
+ Force bool `arg:"--force" help:"force redo things"`
+ Dirty bool `arg:"--dirty" help:"update git CheckDirty()"`
+ PatchSet string `arg:"--patchset" help:"make patch set"`
}
func (args) Version() string {
diff --git a/findRepos.go b/findRepos.go
index e01ca4b..8739d29 100644
--- a/findRepos.go
+++ b/findRepos.go
@@ -4,36 +4,59 @@ import (
"go.wit.com/log"
)
-func findRepos() bool {
- var done bool = false
- if argv.Find != nil {
- if argv.Find.All {
- findAll()
- done = true
- }
+func (f *FindCmd) findRepos() {
+ if f == nil {
+ findMine()
+ return
+ }
- if argv.Find.Private {
- findPrivate()
- done = true
- }
+ if f.All {
+ findAll(f)
+ return
+ }
- if argv.Find.Mine {
- findMine()
- done = true
- }
- if argv.Find.Favorites {
- findFavorites()
- done = true
- }
+ if f.Private {
+ findPrivate()
+ return
}
- // this is the 'default' behavior when no command line arguments are given
- // if no argv was set, select repos marked as 'mine'
- if !done {
+ if f.Mine {
findMine()
- done = true
+ return
+ }
+ if f.Favorites {
+ findFavorites()
+ return
}
- return done
+
+ findMine()
+}
+
+func findRepos(fargv *FindCmd) {
+ if fargv == nil {
+ findMine()
+ return
+ }
+ if fargv.All {
+ findAll(fargv)
+ return
+ }
+
+ if fargv.Private {
+ findPrivate()
+ return
+ }
+
+ if fargv.Mine {
+ findMine()
+ return
+ }
+ if fargv.Favorites {
+ findFavorites()
+ return
+ }
+
+ findMine()
}
func findPrivate() {
@@ -70,12 +93,13 @@ func findFavorites() {
}
}
-func findAll() {
+// func (f *FindCmd) findRepos() {
+func findAll(fargv *FindCmd) {
all := me.forge.Repos.SortByFullPath()
for all.Scan() {
repo := all.Next()
me.found.AppendUniqueGoPath(repo)
- if me.forge.Config.IsReadOnly(repo.GetGoPath()) && !argv.Find.ReadOnly {
+ if me.forge.Config.IsReadOnly(repo.GetGoPath()) && !fargv.ReadOnly {
if repo.ReadOnly {
continue
}
diff --git a/main.go b/main.go
index 330bc8e..20f2930 100644
--- a/main.go
+++ b/main.go
@@ -41,13 +41,30 @@ func main() {
me.forge = forgepb.Init()
me.found = new(gitpb.Repos)
- if argv.User {
+ if argv.User != nil {
me.forge.CheckoutUser()
+ me.forge = forgepb.Init()
+ me.found = new(gitpb.Repos)
+ argv.User.findRepos()
+ doCobol()
okExit("")
}
- if argv.Master {
+ if argv.Devel != nil {
+ me.forge.CheckoutDevel()
+ me.forge = forgepb.Init()
+ me.found = new(gitpb.Repos)
+ argv.Devel.findRepos()
+ doCobol()
+ okExit("")
+ }
+
+ if argv.Master != nil {
me.forge.CheckoutMaster()
+ me.forge = forgepb.Init()
+ me.found = new(gitpb.Repos)
+ argv.Master.findRepos()
+ doCobol()
okExit("")
}
@@ -75,37 +92,39 @@ func main() {
me.forge.ConfigPrintTable()
okExit("")
}
- } else {
- findRepos()
}
- // okExit("")
log.Info("found", me.found.Len(), "repos. found", len(me.foundPaths), "paths from .config/forge")
// now, do something to all of them (or just print out a table of them)
var done bool = false
if argv.Dirty {
+ findRepos(argv.Find)
doCheckDirty()
okExit("")
done = true
}
if argv.Scan {
+ findRepos(argv.Find)
doScan()
done = true
}
- if argv.GitPull {
+ if argv.GitPull != nil {
+ argv.GitPull.findRepos()
doGitPull()
done = true
}
if argv.GitReset {
+ findRepos(argv.Find)
doGitReset()
done = true
}
- if argv.List {
+ if argv.List != nil {
+ argv.List.findRepos()
// print out the repos
doCobol()
done = true
@@ -136,7 +155,11 @@ func main() {
okExit("")
}
}
- // open the gui
- doGui()
+ // open the gui unless the user performed some other
+ // things from the command line
+ // basically, if you run just 'forge' it'll open the GUI
+ if !done {
+ doGui()
+ }
okExit("")
}