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
|
||||
|
||||
tag:
|
||||
forge tag list
|
||||
forge show tag
|
||||
|
||||
vet:
|
||||
@GO111MODULE=off go vet
|
||||
|
|
91
argv.go
91
argv.go
|
@ -34,12 +34,15 @@ type args struct {
|
|||
|
||||
type ShowCmd struct {
|
||||
Dirty *EmptyCmd `arg:"subcommand:dirty" help:"show dirty git repos"`
|
||||
List *EmptyCmd `arg:"subcommand:list" help:"print a table of the current repos"`
|
||||
Tag *TagCmd `arg:"subcommand:tag" help:"manage git tags"`
|
||||
Build string `arg:"--build" help:"build a repo"`
|
||||
Install string `arg:"--install" help:"install a repo"`
|
||||
BuildForge bool `arg:"--forge-rebuild" help:"download and rebuild forge"`
|
||||
URL string `arg:"--connect" help:"forge url"`
|
||||
Repo *RepoCmd `arg:"subcommand:repo" help:"print a table of the current repos"`
|
||||
Tag *TagCmd `arg:"subcommand:tag" help:"show git tags"`
|
||||
// Build string `arg:"--build" help:"build a repo"`
|
||||
// Install string `arg:"--install" help:"install a repo"`
|
||||
// BuildForge bool `arg:"--forge-rebuild" help:"download and rebuild forge"`
|
||||
// URL string `arg:"--connect" help:"forge url"`
|
||||
}
|
||||
|
||||
type RepoCmd struct {
|
||||
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"`
|
||||
|
@ -65,8 +68,8 @@ type CommitCmd struct {
|
|||
type testCmd string
|
||||
|
||||
type CleanCmd struct {
|
||||
Verify *EmptyCmd `arg:"subcommand:verify" help:"rescan repo"`
|
||||
Repo string `arg:"--repo" help:"which repo to look at"`
|
||||
// Verify *EmptyCmd `arg:"subcommand:verify" help:"rescan repo"`
|
||||
// Repo string `arg:"--repo" help:"which repo to look at"`
|
||||
}
|
||||
|
||||
type CleanDevelCmd struct {
|
||||
|
@ -87,9 +90,10 @@ type SubmitCmd struct {
|
|||
}
|
||||
|
||||
type PullCmd struct {
|
||||
Check *EmptyCmd `arg:"subcommand:check" help:"check repo versions"`
|
||||
Dirty *EmptyCmd `arg:"subcommand:dirty" help:"only check dirty repos"`
|
||||
Patches *EmptyCmd `arg:"subcommand:patches" help:"only check repos with patches"`
|
||||
Force bool `arg:"--force" help:"try to strong-arm things"`
|
||||
// Check *EmptyCmd `arg:"subcommand:check" help:"check repo versions"`
|
||||
// Dirty *EmptyCmd `arg:"subcommand:dirty" help:"only check dirty repos"`
|
||||
// Patches *EmptyCmd `arg:"subcommand:patches" help:"only check repos with patches"`
|
||||
}
|
||||
|
||||
type TagCmd struct {
|
||||
|
@ -98,6 +102,27 @@ type TagCmd struct {
|
|||
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 {
|
||||
Path string `arg:"--path" help:"absolute 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"`
|
||||
}
|
||||
|
||||
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 {
|
||||
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 {
|
||||
return ARGNAME
|
||||
}
|
||||
|
@ -190,6 +180,11 @@ func ifBlank(arg string) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
func (a args) DoAutoComplete(autoArgv *prep.Auto) {
|
||||
DoAutoComplete(autoArgv)
|
||||
func (a args) DoAutoComplete(pb *prep.Auto) {
|
||||
if pb.Cmd == "" {
|
||||
pb.Autocomplete3([]string{"checkout", "clean", "commit", "config", "gui", "merge", "normal", "patch", "pull", "show"})
|
||||
} else {
|
||||
pb.SubCommand(pb.Argv...)
|
||||
}
|
||||
os.Exit(0)
|
||||
}
|
||||
|
|
|
@ -6,9 +6,7 @@ package main
|
|||
import (
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
||||
"go.wit.com/lib/gui/shell"
|
||||
"go.wit.com/lib/protobuf/forgepb"
|
||||
"go.wit.com/lib/protobuf/gitpb"
|
||||
"go.wit.com/log"
|
||||
|
@ -58,6 +56,7 @@ if repo.IsSubset("user", "devel") {
|
|||
func doClean() error {
|
||||
setForgeMode(forgepb.ForgeMode_CLEAN)
|
||||
|
||||
/*
|
||||
if argv.Clean.Verify != nil {
|
||||
stats := me.forge.RillRepos(checkRemoteBranches)
|
||||
for path, stat := range stats {
|
||||
|
@ -73,6 +72,7 @@ func doClean() error {
|
|||
// 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'
|
||||
if err := me.forge.DoAllCheckoutMaster(); err != nil {
|
||||
|
|
12
doFind.go
12
doFind.go
|
@ -19,7 +19,7 @@ func doFind() *gitpb.Repos {
|
|||
return findAll()
|
||||
}
|
||||
|
||||
if argv.Show.Mine {
|
||||
if argv.Show.Repo.Mine {
|
||||
return findMine()
|
||||
}
|
||||
|
||||
|
@ -35,19 +35,19 @@ func findRepos() *gitpb.Repos {
|
|||
return findMine()
|
||||
}
|
||||
|
||||
if argv.Show.All {
|
||||
if argv.Show.Repo.All {
|
||||
return findAll()
|
||||
}
|
||||
|
||||
if argv.Show.Private {
|
||||
if argv.Show.Repo.Private {
|
||||
return findPrivate()
|
||||
}
|
||||
|
||||
if argv.Show.Mine {
|
||||
if argv.Show.Repo.Mine {
|
||||
return findMine()
|
||||
}
|
||||
|
||||
if argv.Show.Favorites {
|
||||
if argv.Show.Repo.Favorites {
|
||||
return findFavorites()
|
||||
}
|
||||
|
||||
|
@ -55,7 +55,7 @@ func findRepos() *gitpb.Repos {
|
|||
return me.forge.FindDirty()
|
||||
}
|
||||
|
||||
if argv.Show.User {
|
||||
if argv.Show.Repo.User {
|
||||
return findUser()
|
||||
}
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ import (
|
|||
|
||||
// is every repo on the devel branch?
|
||||
func doPull() error {
|
||||
/*
|
||||
if argv.Pull.Check != nil {
|
||||
// stats := me.forge.RillFuncError(rillPull)
|
||||
log.Info("TODO: actually git pull here? this is a bad idea. stopping.")
|
||||
|
@ -34,6 +35,7 @@ func doPull() error {
|
|||
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
|
||||
if me.forge.Config.Mode == forgepb.ForgeMode_NORMAL {
|
||||
|
@ -41,7 +43,7 @@ func doPull() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
if argv.Force == true {
|
||||
if argv.Pull.Force {
|
||||
now := time.Now()
|
||||
stats := me.forge.RillFuncError(rillPull)
|
||||
count := me.forge.RillReload()
|
||||
|
|
Loading…
Reference in New Issue