more accurate autocomplete
This commit is contained in:
parent
71a5b271a8
commit
a478df2dcc
2
Makefile
2
Makefile
|
@ -9,7 +9,7 @@ BUILDTIME = $(shell date +%Y.%m.%d_%H%M)
|
||||||
default: install-verbose tag
|
default: install-verbose tag
|
||||||
|
|
||||||
tag:
|
tag:
|
||||||
forge tag list
|
forge show tag
|
||||||
|
|
||||||
vet:
|
vet:
|
||||||
@GO111MODULE=off go vet
|
@GO111MODULE=off go vet
|
||||||
|
|
105
argv.go
105
argv.go
|
@ -33,19 +33,22 @@ type args struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type ShowCmd struct {
|
type ShowCmd struct {
|
||||||
Dirty *EmptyCmd `arg:"subcommand:dirty" help:"show dirty git repos"`
|
Dirty *EmptyCmd `arg:"subcommand:dirty" help:"show dirty git repos"`
|
||||||
List *EmptyCmd `arg:"subcommand:list" help:"print a table of the current repos"`
|
Repo *RepoCmd `arg:"subcommand:repo" help:"print a table of the current repos"`
|
||||||
Tag *TagCmd `arg:"subcommand:tag" help:"manage git tags"`
|
Tag *TagCmd `arg:"subcommand:tag" help:"show git tags"`
|
||||||
Build string `arg:"--build" help:"build a repo"`
|
// Build string `arg:"--build" help:"build a repo"`
|
||||||
Install string `arg:"--install" help:"install a repo"`
|
// Install string `arg:"--install" help:"install a repo"`
|
||||||
BuildForge bool `arg:"--forge-rebuild" help:"download and rebuild forge"`
|
// BuildForge bool `arg:"--forge-rebuild" help:"download and rebuild forge"`
|
||||||
URL string `arg:"--connect" help:"forge url"`
|
// URL string `arg:"--connect" help:"forge url"`
|
||||||
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"`
|
type RepoCmd struct {
|
||||||
Private bool `arg:"--private" help:"your private repos from your .config/forge/"`
|
All bool `arg:"--all" help:"select every repo (the default)"`
|
||||||
User bool `arg:"--user" help:"show repos on the user branch"`
|
Mine bool `arg:"--mine" help:"your repos as defined in the forge config"`
|
||||||
Full bool `arg:"--full" help:"show full repo names"`
|
Favorites bool `arg:"--favorites" help:"your repos configured as favorites"`
|
||||||
|
Private bool `arg:"--private" help:"your private repos from your .config/forge/"`
|
||||||
|
User bool `arg:"--user" help:"show repos on the user branch"`
|
||||||
|
Full bool `arg:"--full" help:"show full repo names"`
|
||||||
// ReadOnly bool `arg:"--readonly" help:"include read-only repos"`
|
// ReadOnly bool `arg:"--readonly" help:"include read-only repos"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,8 +68,8 @@ type CommitCmd struct {
|
||||||
type testCmd string
|
type testCmd string
|
||||||
|
|
||||||
type CleanCmd struct {
|
type CleanCmd struct {
|
||||||
Verify *EmptyCmd `arg:"subcommand:verify" help:"rescan repo"`
|
// Verify *EmptyCmd `arg:"subcommand:verify" help:"rescan repo"`
|
||||||
Repo string `arg:"--repo" help:"which repo to look at"`
|
// Repo string `arg:"--repo" help:"which repo to look at"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type CleanDevelCmd struct {
|
type CleanDevelCmd struct {
|
||||||
|
@ -87,9 +90,10 @@ type SubmitCmd struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type PullCmd struct {
|
type PullCmd struct {
|
||||||
Check *EmptyCmd `arg:"subcommand:check" help:"check repo versions"`
|
Force bool `arg:"--force" help:"try to strong-arm things"`
|
||||||
Dirty *EmptyCmd `arg:"subcommand:dirty" help:"only check dirty repos"`
|
// Check *EmptyCmd `arg:"subcommand:check" help:"check repo versions"`
|
||||||
Patches *EmptyCmd `arg:"subcommand:patches" help:"only check repos with patches"`
|
// Dirty *EmptyCmd `arg:"subcommand:dirty" help:"only check dirty repos"`
|
||||||
|
// Patches *EmptyCmd `arg:"subcommand:patches" help:"only check repos with patches"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type TagCmd struct {
|
type TagCmd struct {
|
||||||
|
@ -98,6 +102,27 @@ type TagCmd struct {
|
||||||
Delete string `arg:"--delete" help:"delete a tag"`
|
Delete string `arg:"--delete" help:"delete a tag"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type CheckoutCmd struct {
|
||||||
|
User *EmptyCmd `arg:"subcommand:user" help:"git checkout user"`
|
||||||
|
Devel *EmptyCmd `arg:"subcommand:devel" help:"git checkout devel"`
|
||||||
|
Master *EmptyCmd `arg:"subcommand:master" help:"git checkout master"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type MergeCmd struct {
|
||||||
|
All bool `arg:"--all" help:"merge all"`
|
||||||
|
Devel *EmptyCmd `arg:"subcommand:devel" help:"merge user to devel"`
|
||||||
|
Master *EmptyCmd `arg:"subcommand:master" help:"merge devel to master"`
|
||||||
|
Publish *EmptyCmd `arg:"subcommand:publish" help:"increment versions and publish master branch"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ConfigCmd struct {
|
||||||
|
Add *ConfigAddCmd `arg:"subcommand:add" help:"add a config setting"`
|
||||||
|
Fix *EmptyCmd `arg:"subcommand:fix" help:"fix .config/forge/ and/or repos.pb protobuf file"`
|
||||||
|
List *EmptyCmd `arg:"subcommand:list" help:"list your config settings"`
|
||||||
|
Delete string `arg:"--delete" help:"delete this repo"`
|
||||||
|
Register string `arg:"--register" help:"register your git URL (foo.com/mystuff) or (github.com/foo/bar)"`
|
||||||
|
}
|
||||||
|
|
||||||
type ConfigAddCmd struct {
|
type ConfigAddCmd struct {
|
||||||
Path string `arg:"--path" help:"absolute path of the git repo"`
|
Path string `arg:"--path" help:"absolute path of the git repo"`
|
||||||
GoPath string `arg:"--gopath" help:"GO path of the git repo"`
|
GoPath string `arg:"--gopath" help:"GO path of the git repo"`
|
||||||
|
@ -113,26 +138,6 @@ type ConfigAddCmd struct {
|
||||||
User string `arg:"--user" help:"the git user branch name"`
|
User string `arg:"--user" help:"the git user branch name"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type CheckoutCmd struct {
|
|
||||||
User *EmptyCmd `arg:"subcommand:user" help:"git checkout user"`
|
|
||||||
Devel *EmptyCmd `arg:"subcommand:devel" help:"git checkout devel"`
|
|
||||||
Master *EmptyCmd `arg:"subcommand:master" help:"git checkout master"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type MergeCmd struct {
|
|
||||||
Devel *EmptyCmd `arg:"subcommand:devel" help:"merge user to devel"`
|
|
||||||
Master *EmptyCmd `arg:"subcommand:master" help:"merge devel to master"`
|
|
||||||
Publish *EmptyCmd `arg:"subcommand:publish" help:"increment versions and publish master branch"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type ConfigCmd struct {
|
|
||||||
Add *ConfigAddCmd `arg:"subcommand:add" help:"add a config setting"`
|
|
||||||
Fix *EmptyCmd `arg:"subcommand:fix" help:"fix .config/forge/ and/or repos.pb protobuf file"`
|
|
||||||
List *EmptyCmd `arg:"subcommand:list" help:"list your config settings"`
|
|
||||||
Delete string `arg:"--delete" help:"delete this repo"`
|
|
||||||
Register string `arg:"--register" help:"register your git URL (foo.com/mystuff) or (github.com/foo/bar)"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (args) Version() string {
|
func (args) Version() string {
|
||||||
return ARGNAME + " " + VERSION + " Built on " + BUILDTIME
|
return ARGNAME + " " + VERSION + " Built on " + BUILDTIME
|
||||||
}
|
}
|
||||||
|
@ -163,21 +168,6 @@ forge -- a tool to manage lots of git repos. forge includes a GUI and TUI.
|
||||||
`
|
`
|
||||||
}
|
}
|
||||||
|
|
||||||
// handles shell autocomplete
|
|
||||||
func DoAutoComplete(pb *prep.Auto) {
|
|
||||||
switch pb.Cmd {
|
|
||||||
case "show":
|
|
||||||
pb.SubCommand(pb.Cmd)
|
|
||||||
default:
|
|
||||||
if pb.Cmd == "" {
|
|
||||||
pb.Autocomplete2("checkout clean commit normal merge show")
|
|
||||||
} else {
|
|
||||||
pb.SubCommand(pb.Cmd)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
os.Exit(0)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (args) Appname() string {
|
func (args) Appname() string {
|
||||||
return ARGNAME
|
return ARGNAME
|
||||||
}
|
}
|
||||||
|
@ -190,6 +180,11 @@ func ifBlank(arg string) bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a args) DoAutoComplete(autoArgv *prep.Auto) {
|
func (a args) DoAutoComplete(pb *prep.Auto) {
|
||||||
DoAutoComplete(autoArgv)
|
if pb.Cmd == "" {
|
||||||
|
pb.Autocomplete3([]string{"checkout", "clean", "commit", "config", "gui", "merge", "normal", "patch", "pull", "show"})
|
||||||
|
} else {
|
||||||
|
pb.SubCommand(pb.Argv...)
|
||||||
|
}
|
||||||
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
30
doClean.go
30
doClean.go
|
@ -6,9 +6,7 @@ package main
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"time"
|
|
||||||
|
|
||||||
"go.wit.com/lib/gui/shell"
|
|
||||||
"go.wit.com/lib/protobuf/forgepb"
|
"go.wit.com/lib/protobuf/forgepb"
|
||||||
"go.wit.com/lib/protobuf/gitpb"
|
"go.wit.com/lib/protobuf/gitpb"
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
|
@ -58,21 +56,23 @@ if repo.IsSubset("user", "devel") {
|
||||||
func doClean() error {
|
func doClean() error {
|
||||||
setForgeMode(forgepb.ForgeMode_CLEAN)
|
setForgeMode(forgepb.ForgeMode_CLEAN)
|
||||||
|
|
||||||
if argv.Clean.Verify != nil {
|
/*
|
||||||
stats := me.forge.RillRepos(checkRemoteBranches)
|
if argv.Clean.Verify != nil {
|
||||||
for path, stat := range stats {
|
stats := me.forge.RillRepos(checkRemoteBranches)
|
||||||
if stat.Err == nil {
|
for path, stat := range stats {
|
||||||
continue
|
if stat.Err == nil {
|
||||||
}
|
continue
|
||||||
dur := stat.End.Sub(stat.Start)
|
}
|
||||||
if dur > time.Second {
|
dur := stat.End.Sub(stat.Start)
|
||||||
log.Infof("%s checkRemoteBranches() took a long time (%s) (err=%v)\n", path, shell.FormatDuration(dur), stat.Err)
|
if dur > time.Second {
|
||||||
|
log.Infof("%s checkRemoteBranches() took a long time (%s) (err=%v)\n", path, shell.FormatDuration(dur), stat.Err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
// log.Infof("%-60s, %-60s %v %s\n", stat.Start, stat.End.String(), dur, path)
|
||||||
|
// log.Infof("%-30v %s %v\n", dur, path, stat.Err)
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
// log.Infof("%-60s, %-60s %v %s\n", stat.Start, stat.End.String(), dur, path)
|
*/
|
||||||
// log.Infof("%-30v %s %v\n", dur, path, stat.Err)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// fix this to work, then delete all the other options for "forge clean'
|
// fix this to work, then delete all the other options for "forge clean'
|
||||||
if err := me.forge.DoAllCheckoutMaster(); err != nil {
|
if err := me.forge.DoAllCheckoutMaster(); err != nil {
|
||||||
|
|
12
doFind.go
12
doFind.go
|
@ -19,7 +19,7 @@ func doFind() *gitpb.Repos {
|
||||||
return findAll()
|
return findAll()
|
||||||
}
|
}
|
||||||
|
|
||||||
if argv.Show.Mine {
|
if argv.Show.Repo.Mine {
|
||||||
return findMine()
|
return findMine()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,19 +35,19 @@ func findRepos() *gitpb.Repos {
|
||||||
return findMine()
|
return findMine()
|
||||||
}
|
}
|
||||||
|
|
||||||
if argv.Show.All {
|
if argv.Show.Repo.All {
|
||||||
return findAll()
|
return findAll()
|
||||||
}
|
}
|
||||||
|
|
||||||
if argv.Show.Private {
|
if argv.Show.Repo.Private {
|
||||||
return findPrivate()
|
return findPrivate()
|
||||||
}
|
}
|
||||||
|
|
||||||
if argv.Show.Mine {
|
if argv.Show.Repo.Mine {
|
||||||
return findMine()
|
return findMine()
|
||||||
}
|
}
|
||||||
|
|
||||||
if argv.Show.Favorites {
|
if argv.Show.Repo.Favorites {
|
||||||
return findFavorites()
|
return findFavorites()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ func findRepos() *gitpb.Repos {
|
||||||
return me.forge.FindDirty()
|
return me.forge.FindDirty()
|
||||||
}
|
}
|
||||||
|
|
||||||
if argv.Show.User {
|
if argv.Show.Repo.User {
|
||||||
return findUser()
|
return findUser()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
40
doPull.go
40
doPull.go
|
@ -14,26 +14,28 @@ import (
|
||||||
|
|
||||||
// is every repo on the devel branch?
|
// is every repo on the devel branch?
|
||||||
func doPull() error {
|
func doPull() error {
|
||||||
if argv.Pull.Check != nil {
|
/*
|
||||||
// stats := me.forge.RillFuncError(rillPull)
|
if argv.Pull.Check != nil {
|
||||||
log.Info("TODO: actually git pull here? this is a bad idea. stopping.")
|
// stats := me.forge.RillFuncError(rillPull)
|
||||||
submit := gitpb.NewRepos()
|
log.Info("TODO: actually git pull here? this is a bad idea. stopping.")
|
||||||
for repo := range me.forge.Repos.IterByFullPath() {
|
submit := gitpb.NewRepos()
|
||||||
newrepo := new(gitpb.Repo)
|
for repo := range me.forge.Repos.IterByFullPath() {
|
||||||
newrepo.MasterHash = repo.MasterHash
|
newrepo := new(gitpb.Repo)
|
||||||
newrepo.DevelHash = repo.DevelHash
|
newrepo.MasterHash = repo.MasterHash
|
||||||
newrepo.Namespace = repo.Namespace
|
newrepo.DevelHash = repo.DevelHash
|
||||||
newrepo.URL = repo.URL
|
newrepo.Namespace = repo.Namespace
|
||||||
submit.Append(newrepo)
|
newrepo.URL = repo.URL
|
||||||
}
|
submit.Append(newrepo)
|
||||||
updatepb, regPB, err := submit.HttpPost(myServer(), "check")
|
}
|
||||||
if regPB == nil || err != nil {
|
updatepb, regPB, err := submit.HttpPost(myServer(), "check")
|
||||||
log.Info("regPB==nil or err:", err)
|
if regPB == nil || err != nil {
|
||||||
|
log.Info("regPB==nil or err:", err)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
log.Infof("pull check %s pb.Len()=%d client.Len()=%d server.Len()=%d err=%v\n", regPB.URL, updatepb.Len(), regPB.ClientDataLen, regPB.ServerDataLen, err)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
log.Infof("pull check %s pb.Len()=%d client.Len()=%d server.Len()=%d err=%v\n", regPB.URL, updatepb.Len(), regPB.ClientDataLen, regPB.ServerDataLen, err)
|
*/
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// below this, you must not be in 'normal' mode
|
// below this, you must not be in 'normal' mode
|
||||||
if me.forge.Config.Mode == forgepb.ForgeMode_NORMAL {
|
if me.forge.Config.Mode == forgepb.ForgeMode_NORMAL {
|
||||||
|
@ -41,7 +43,7 @@ func doPull() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if argv.Force == true {
|
if argv.Pull.Force {
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
stats := me.forge.RillFuncError(rillPull)
|
stats := me.forge.RillFuncError(rillPull)
|
||||||
count := me.forge.RillReload()
|
count := me.forge.RillReload()
|
||||||
|
|
Loading…
Reference in New Issue