more argv improvements
This commit is contained in:
parent
9818e8d1ee
commit
8b3be0ab42
10
Makefile
10
Makefile
|
@ -35,19 +35,19 @@ gocui: install
|
|||
forge --gui gocui >/tmp/forge.log 2>&1
|
||||
|
||||
private: install
|
||||
forge find --private
|
||||
forge list --private
|
||||
|
||||
fix: install
|
||||
forge --fix find --all
|
||||
forge --fix list --all
|
||||
|
||||
list-all: install
|
||||
forge list --all
|
||||
|
||||
git-reset: install
|
||||
forge --do-git-reset find --all
|
||||
forge --do-git-reset list --all
|
||||
|
||||
readonly: install
|
||||
forge --list find --readonly
|
||||
forge --list list --readonly
|
||||
|
||||
config: install
|
||||
forge --config
|
||||
|
@ -74,7 +74,7 @@ patches-list: install
|
|||
forge --list-patchset
|
||||
|
||||
dirty: install
|
||||
forge --no-gui find --all --dirty
|
||||
forge dirty --all
|
||||
|
||||
restart:
|
||||
reset
|
||||
|
|
12
argv.go
12
argv.go
|
@ -7,32 +7,30 @@ package main
|
|||
var argv args
|
||||
|
||||
type FindCmd struct {
|
||||
All bool `arg:"--all" help:"select every repo"`
|
||||
ReadOnly bool `arg:"--readonly" help:"include read-only repos"`
|
||||
All bool `arg:"--all" help:"select every repo (the default)"`
|
||||
Mine bool `arg:"--mine" help:"your repos as defined in the forge config"`
|
||||
Favorites bool `arg:"--favorites" help:"your repos configured as favorites"`
|
||||
Private bool `arg:"--private" help:"private repos from your .config/forge/"`
|
||||
Private bool `arg:"--private" help:"your private repos from your .config/forge/"`
|
||||
// ReadOnly bool `arg:"--readonly" help:"include read-only repos"`
|
||||
}
|
||||
|
||||
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"`
|
||||
Dirty *FindCmd `arg:"subcommand:dirty" help:"check if your git repos are dirty"`
|
||||
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 *FindCmd `arg:"subcommand: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"`
|
||||
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"`
|
||||
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"`
|
||||
}
|
||||
|
||||
|
|
24
cobol.go
24
cobol.go
|
@ -34,7 +34,7 @@ func doCobol() {
|
|||
log.DaemonMode(true)
|
||||
|
||||
// log.Info(standardStart5("gopath", "cur name", "master", "user", "repo type"))
|
||||
log.Info(standardStart8("gopath", "cur name", "age", "target", "master", "devel", "user", "curver", "repo type"))
|
||||
log.Info(standardStart8("repopath", "cur name", "age", "target", "master", "devel", "user", "curver", "repo type"))
|
||||
all := me.found.SortByFullPath()
|
||||
for all.Scan() {
|
||||
repo := all.Next()
|
||||
|
@ -133,7 +133,8 @@ func verifyPrint(repo *gitpb.Repo) {
|
|||
if repo.IsDirty() {
|
||||
end += "(dirty) "
|
||||
}
|
||||
s := make(map[string]string)
|
||||
// s := make(map[string]string)
|
||||
/*
|
||||
if !verify(repo, s) {
|
||||
log.Info("going to delete", repo.GetGoPath())
|
||||
if argv.Fix {
|
||||
|
@ -143,18 +144,21 @@ func verifyPrint(repo *gitpb.Repo) {
|
|||
log.Info("need argv --fix to delete", repo.GetGoPath())
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
var mhort string = s["mver"] // master version
|
||||
var dhort string = s["dver"] // devel version
|
||||
var uhort string = s["uver"] // user version
|
||||
var thort string = s["tver"] // target version
|
||||
var chort string = s["cver"] // current version
|
||||
var cname string = s["cname"] // current branch name git is on now
|
||||
var mhort string = repo.GetMasterVersion()
|
||||
var dhort string = repo.GetDevelVersion()
|
||||
var uhort string = repo.GetUserVersion()
|
||||
var thort string = repo.GetTargetVersion()
|
||||
var chort string = repo.GetCurrentBranchVersion()
|
||||
var cname string = repo.GetCurrentBranchName()
|
||||
|
||||
var gopath string = repo.GetGoPath()
|
||||
var rtype string = repo.GetRepoType()
|
||||
|
||||
age := shell.FormatDuration(repo.NewestAge())
|
||||
|
||||
// start := fmt.Sprintf("%-40s %-12s %-12s %-12s %-8s", s["gopath"], cname, mhort, uhort, s["rtype"])
|
||||
start := standardStart8(s["gopath"], cname, age, thort, mhort, dhort, uhort, chort, s["rtype"])
|
||||
start := standardStart8(gopath, cname, age, thort, mhort, dhort, uhort, chort, rtype)
|
||||
|
||||
if me.forge.Config.IsReadOnly(repo.GetGoPath()) {
|
||||
end += "(readonly) "
|
||||
|
|
|
@ -39,7 +39,7 @@ func doGitPull() {
|
|||
|
||||
func doCheckDirty() {
|
||||
now := time.Now()
|
||||
all := me.forge.Repos.SortByFullPath()
|
||||
all := me.found.SortByFullPath()
|
||||
for all.Scan() {
|
||||
repo := all.Next()
|
||||
dirty := repo.IsDirty()
|
||||
|
|
|
@ -3,23 +3,20 @@ package main
|
|||
import "go.wit.com/log"
|
||||
|
||||
// retuns true if nothing was done
|
||||
func findConfig() bool {
|
||||
var done bool = false
|
||||
if argv.Find != nil {
|
||||
if argv.Find.Mine {
|
||||
func findConfig(fargv *FindCmd) {
|
||||
if fargv == nil {
|
||||
findConfigAll()
|
||||
return
|
||||
}
|
||||
if fargv.Mine {
|
||||
findConfigMine()
|
||||
done = true
|
||||
return
|
||||
}
|
||||
if argv.Find.All {
|
||||
if fargv.All {
|
||||
findConfigAll()
|
||||
done = true
|
||||
return
|
||||
}
|
||||
}
|
||||
if !done {
|
||||
findConfigAll()
|
||||
done = true
|
||||
}
|
||||
return done
|
||||
}
|
||||
|
||||
// finds config repos that are writable
|
||||
|
|
23
findRepos.go
23
findRepos.go
|
@ -1,9 +1,6 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"go.wit.com/log"
|
||||
)
|
||||
|
||||
// by default, work against every repo
|
||||
func (f *FindCmd) findRepos() {
|
||||
if f == nil {
|
||||
findMine()
|
||||
|
@ -29,7 +26,7 @@ func (f *FindCmd) findRepos() {
|
|||
return
|
||||
}
|
||||
|
||||
findMine()
|
||||
findAll(f)
|
||||
}
|
||||
|
||||
func findRepos(fargv *FindCmd) {
|
||||
|
@ -93,26 +90,10 @@ func findFavorites() {
|
|||
}
|
||||
}
|
||||
|
||||
// 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()) && !fargv.ReadOnly {
|
||||
if repo.ReadOnly {
|
||||
continue
|
||||
}
|
||||
log.Info("todo: ConfigSave() readonly flag on repo is wrong", repo.GetGoPath())
|
||||
repo.ReadOnly = true
|
||||
configSave = true
|
||||
continue
|
||||
}
|
||||
}
|
||||
/*
|
||||
if configsave {
|
||||
log.Info("should ConfigSave here")
|
||||
me.forge.Repos.ConfigSave()
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
|
13
main.go
13
main.go
|
@ -87,26 +87,25 @@ func main() {
|
|||
}
|
||||
|
||||
// first find the repos or gopaths to operate on
|
||||
if argv.Config {
|
||||
if findConfig() {
|
||||
if argv.Config != nil {
|
||||
findConfig(argv.Config)
|
||||
me.forge.ConfigPrintTable()
|
||||
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)
|
||||
if argv.Dirty != nil {
|
||||
argv.Dirty.findRepos()
|
||||
doCheckDirty()
|
||||
okExit("")
|
||||
done = true
|
||||
}
|
||||
|
||||
if argv.Scan {
|
||||
findRepos(argv.Find)
|
||||
findRepos(argv.List)
|
||||
doScan()
|
||||
done = true
|
||||
}
|
||||
|
@ -118,7 +117,7 @@ func main() {
|
|||
}
|
||||
|
||||
if argv.GitReset {
|
||||
findRepos(argv.Find)
|
||||
findRepos(argv.List)
|
||||
doGitReset()
|
||||
done = true
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue