more argv cleanups
This commit is contained in:
parent
778de10e87
commit
3505a66d84
2
Makefile
2
Makefile
|
@ -74,7 +74,7 @@ patches-list: install
|
|||
forge --list-patches --url "http://localhost:2233/"
|
||||
|
||||
dirty: install
|
||||
forge --dirty
|
||||
forge do --dirty
|
||||
|
||||
restart:
|
||||
reset
|
||||
|
|
4
argv.go
4
argv.go
|
@ -20,6 +20,7 @@ type DoCmd struct {
|
|||
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()"`
|
||||
}
|
||||
|
||||
type args struct {
|
||||
|
@ -31,7 +32,6 @@ type args struct {
|
|||
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"`
|
||||
Dirty bool `arg:"--dirty" help:"git CheckDirty() on every 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"`
|
||||
|
@ -59,5 +59,3 @@ Examples:
|
|||
# these options are intended for automation. You probably just want to use the GUI.
|
||||
`
|
||||
}
|
||||
|
||||
// forge --map lib/foo https://github.com/me/myfoo # map go.wit.com/lib/foo -> github.com/me/myfoo
|
||||
|
|
26
doCommon.go
26
doCommon.go
|
@ -1,6 +1,9 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"go.wit.com/lib/gui/shell"
|
||||
"go.wit.com/lib/protobuf/gitpb"
|
||||
"go.wit.com/log"
|
||||
)
|
||||
|
@ -33,6 +36,29 @@ func doGitPull() {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
func doCheckDirty() {
|
||||
now := time.Now()
|
||||
all := me.forge.Repos.SortByFullPath()
|
||||
for all.Scan() {
|
||||
repo := all.Next()
|
||||
dirty := repo.IsDirty()
|
||||
if repo.CheckDirty() {
|
||||
me.found.AppendUniqueGoPath(repo)
|
||||
if !dirty {
|
||||
configSave = true
|
||||
}
|
||||
} else {
|
||||
if dirty {
|
||||
configSave = true
|
||||
}
|
||||
}
|
||||
}
|
||||
doCobol()
|
||||
log.Info("dirty check took:", shell.FormatDuration(time.Since(now)))
|
||||
me.forge.SetConfigSave(configSave)
|
||||
}
|
||||
|
||||
func doGitReset() {
|
||||
all := me.found.SortByFullPath()
|
||||
for all.Scan() {
|
||||
|
|
50
main.go
50
main.go
|
@ -4,11 +4,9 @@ package main
|
|||
|
||||
import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"go.wit.com/dev/alexflint/arg"
|
||||
"go.wit.com/gui"
|
||||
"go.wit.com/lib/gui/shell"
|
||||
"go.wit.com/lib/protobuf/forgepb"
|
||||
"go.wit.com/lib/protobuf/gitpb"
|
||||
"go.wit.com/log"
|
||||
|
@ -40,11 +38,6 @@ func main() {
|
|||
me.forge = forgepb.Init()
|
||||
me.found = new(gitpb.Repos)
|
||||
|
||||
if configSave {
|
||||
me.forge.ConfigSave()
|
||||
configSave = false
|
||||
}
|
||||
|
||||
if argv.User {
|
||||
me.forge.CheckoutUser()
|
||||
okExit("")
|
||||
|
@ -69,38 +62,6 @@ func main() {
|
|||
okExit("")
|
||||
}
|
||||
|
||||
if argv.Dirty {
|
||||
now := time.Now()
|
||||
all := me.forge.Repos.SortByFullPath()
|
||||
for all.Scan() {
|
||||
repo := all.Next()
|
||||
dirty := repo.IsDirty()
|
||||
if repo.CheckDirty() {
|
||||
me.found.AppendUniqueGoPath(repo)
|
||||
if !dirty {
|
||||
configSave = true
|
||||
}
|
||||
} else {
|
||||
if dirty {
|
||||
configSave = true
|
||||
}
|
||||
}
|
||||
}
|
||||
doCobol()
|
||||
log.Info("dirty check took:", shell.FormatDuration(time.Since(now)))
|
||||
me.forge.SetConfigSave(configSave)
|
||||
okExit("")
|
||||
}
|
||||
|
||||
/*
|
||||
// var count int
|
||||
all := me.forge.Repos.SortByFullPath()
|
||||
for all.Scan() {
|
||||
repo := all.Next()
|
||||
verifyPrint(repo)
|
||||
}
|
||||
*/
|
||||
|
||||
if argv.Fix {
|
||||
okExit("")
|
||||
}
|
||||
|
@ -121,6 +82,12 @@ func main() {
|
|||
// now, do something to all of them (or just print out a table of them)
|
||||
var done bool = false
|
||||
if argv.Do != nil {
|
||||
if argv.Do.Dirty {
|
||||
doCheckDirty()
|
||||
okExit("")
|
||||
done = true
|
||||
}
|
||||
|
||||
if argv.Do.Scan {
|
||||
doScan()
|
||||
done = true
|
||||
|
@ -154,6 +121,11 @@ func main() {
|
|||
okExit("patches")
|
||||
}
|
||||
|
||||
if configSave {
|
||||
me.forge.ConfigSave()
|
||||
configSave = false
|
||||
}
|
||||
|
||||
// if the user doesn't want to open the GUI and
|
||||
// nothing else was specified to be done,
|
||||
// then just list the table to stdout
|
||||
|
|
Loading…
Reference in New Issue