more ideas for command line options
This commit is contained in:
parent
bdaa40c51f
commit
9818e8d1ee
18
Makefile
18
Makefile
|
@ -41,13 +41,13 @@ fix: install
|
||||||
forge --fix find --all
|
forge --fix find --all
|
||||||
|
|
||||||
list-all: install
|
list-all: install
|
||||||
forge find --all
|
forge list --all
|
||||||
|
|
||||||
git-reset: install
|
git-reset: install
|
||||||
forge --do-git-reset find --all
|
forge --do-git-reset find --all
|
||||||
|
|
||||||
readonly: install
|
readonly: install
|
||||||
forge --do-list find --readonly
|
forge --list find --readonly
|
||||||
|
|
||||||
config: install
|
config: install
|
||||||
forge --config
|
forge --config
|
||||||
|
@ -56,13 +56,13 @@ scan: install
|
||||||
forge do --scan
|
forge do --scan
|
||||||
|
|
||||||
pull: install
|
pull: install
|
||||||
forge do --pull
|
forge pull --mine
|
||||||
|
|
||||||
mine: install
|
mine: install
|
||||||
forge --no-gui find --mine
|
forge list --mine
|
||||||
|
|
||||||
all: install
|
all: install
|
||||||
forge --no-gui find --all
|
forge list --all
|
||||||
|
|
||||||
patches: install
|
patches: install
|
||||||
forge --patchset "from makefile"
|
forge --patchset "from makefile"
|
||||||
|
@ -82,8 +82,10 @@ restart:
|
||||||
make private
|
make private
|
||||||
|
|
||||||
user: install
|
user: install
|
||||||
forge find --all --user
|
forge user
|
||||||
forge --no-gui find --all
|
|
||||||
|
devel: install
|
||||||
|
forge devel --all
|
||||||
|
|
||||||
master: install
|
master: install
|
||||||
forge --master
|
forge master --all
|
||||||
|
|
11
argv.go
11
argv.go
|
@ -16,18 +16,19 @@ type FindCmd struct {
|
||||||
|
|
||||||
type args struct {
|
type args struct {
|
||||||
Find *FindCmd `arg:"subcommand:find" help:"select repos (for example, --all or --mine)"`
|
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"`
|
Config bool `arg:"--config" help:"show your .config/forge/ settings"`
|
||||||
ListPatchSet bool `arg:"--list-patchset" help:"list patch sets"`
|
ListPatchSet bool `arg:"--list-patchset" help:"list patch sets"`
|
||||||
DryRun bool `arg:"--dry-run" help:"show what would be run"`
|
DryRun bool `arg:"--dry-run" help:"show what would be run"`
|
||||||
Fix bool `arg:"--fix" help:"fix config, save config & exit"`
|
Fix bool `arg:"--fix" help:"fix config, save config & exit"`
|
||||||
Delete string `arg:"--delete" help:"delete this repo"`
|
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"`
|
URL string `arg:"--connect" help:"gowebd url"`
|
||||||
Register string `arg:"--register" help:"register your git URL (foo.com/mystuff) or (github.com/foo/bar)"`
|
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"`
|
// 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'"`
|
GitReset bool `arg:"--git-reset" help:"run 'git reset --hard'"`
|
||||||
Scan bool `arg:"--scan" help:"reload protobuf from .git/"`
|
Scan bool `arg:"--scan" help:"reload protobuf from .git/"`
|
||||||
Force bool `arg:"--force" help:"force redo things"`
|
Force bool `arg:"--force" help:"force redo things"`
|
||||||
|
|
64
findRepos.go
64
findRepos.go
|
@ -4,36 +4,59 @@ import (
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
func findRepos() bool {
|
func (f *FindCmd) findRepos() {
|
||||||
var done bool = false
|
if f == nil {
|
||||||
if argv.Find != nil {
|
findMine()
|
||||||
if argv.Find.All {
|
return
|
||||||
findAll()
|
|
||||||
done = true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if argv.Find.Private {
|
if f.All {
|
||||||
|
findAll(f)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if f.Private {
|
||||||
findPrivate()
|
findPrivate()
|
||||||
done = true
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if argv.Find.Mine {
|
if f.Mine {
|
||||||
findMine()
|
findMine()
|
||||||
done = true
|
return
|
||||||
}
|
}
|
||||||
if argv.Find.Favorites {
|
if f.Favorites {
|
||||||
findFavorites()
|
findFavorites()
|
||||||
done = true
|
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 {
|
|
||||||
findMine()
|
findMine()
|
||||||
done = true
|
}
|
||||||
|
|
||||||
|
func findRepos(fargv *FindCmd) {
|
||||||
|
if fargv == nil {
|
||||||
|
findMine()
|
||||||
|
return
|
||||||
}
|
}
|
||||||
return done
|
if fargv.All {
|
||||||
|
findAll(fargv)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if fargv.Private {
|
||||||
|
findPrivate()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if fargv.Mine {
|
||||||
|
findMine()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if fargv.Favorites {
|
||||||
|
findFavorites()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
findMine()
|
||||||
}
|
}
|
||||||
|
|
||||||
func findPrivate() {
|
func findPrivate() {
|
||||||
|
@ -70,12 +93,13 @@ func findFavorites() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func findAll() {
|
// func (f *FindCmd) findRepos() {
|
||||||
|
func findAll(fargv *FindCmd) {
|
||||||
all := me.forge.Repos.SortByFullPath()
|
all := me.forge.Repos.SortByFullPath()
|
||||||
for all.Scan() {
|
for all.Scan() {
|
||||||
repo := all.Next()
|
repo := all.Next()
|
||||||
me.found.AppendUniqueGoPath(repo)
|
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 {
|
if repo.ReadOnly {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
39
main.go
39
main.go
|
@ -41,13 +41,30 @@ func main() {
|
||||||
me.forge = forgepb.Init()
|
me.forge = forgepb.Init()
|
||||||
me.found = new(gitpb.Repos)
|
me.found = new(gitpb.Repos)
|
||||||
|
|
||||||
if argv.User {
|
if argv.User != nil {
|
||||||
me.forge.CheckoutUser()
|
me.forge.CheckoutUser()
|
||||||
|
me.forge = forgepb.Init()
|
||||||
|
me.found = new(gitpb.Repos)
|
||||||
|
argv.User.findRepos()
|
||||||
|
doCobol()
|
||||||
okExit("")
|
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.CheckoutMaster()
|
||||||
|
me.forge = forgepb.Init()
|
||||||
|
me.found = new(gitpb.Repos)
|
||||||
|
argv.Master.findRepos()
|
||||||
|
doCobol()
|
||||||
okExit("")
|
okExit("")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,37 +92,39 @@ func main() {
|
||||||
me.forge.ConfigPrintTable()
|
me.forge.ConfigPrintTable()
|
||||||
okExit("")
|
okExit("")
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
findRepos()
|
|
||||||
}
|
}
|
||||||
// okExit("")
|
|
||||||
|
|
||||||
log.Info("found", me.found.Len(), "repos. found", len(me.foundPaths), "paths from .config/forge")
|
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)
|
// now, do something to all of them (or just print out a table of them)
|
||||||
var done bool = false
|
var done bool = false
|
||||||
if argv.Dirty {
|
if argv.Dirty {
|
||||||
|
findRepos(argv.Find)
|
||||||
doCheckDirty()
|
doCheckDirty()
|
||||||
okExit("")
|
okExit("")
|
||||||
done = true
|
done = true
|
||||||
}
|
}
|
||||||
|
|
||||||
if argv.Scan {
|
if argv.Scan {
|
||||||
|
findRepos(argv.Find)
|
||||||
doScan()
|
doScan()
|
||||||
done = true
|
done = true
|
||||||
}
|
}
|
||||||
|
|
||||||
if argv.GitPull {
|
if argv.GitPull != nil {
|
||||||
|
argv.GitPull.findRepos()
|
||||||
doGitPull()
|
doGitPull()
|
||||||
done = true
|
done = true
|
||||||
}
|
}
|
||||||
|
|
||||||
if argv.GitReset {
|
if argv.GitReset {
|
||||||
|
findRepos(argv.Find)
|
||||||
doGitReset()
|
doGitReset()
|
||||||
done = true
|
done = true
|
||||||
}
|
}
|
||||||
|
|
||||||
if argv.List {
|
if argv.List != nil {
|
||||||
|
argv.List.findRepos()
|
||||||
// print out the repos
|
// print out the repos
|
||||||
doCobol()
|
doCobol()
|
||||||
done = true
|
done = true
|
||||||
|
@ -136,7 +155,11 @@ func main() {
|
||||||
okExit("")
|
okExit("")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// open the gui
|
// 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()
|
doGui()
|
||||||
|
}
|
||||||
okExit("")
|
okExit("")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue