autocomplete examples

This commit is contained in:
Jeff Carr 2025-09-25 14:04:50 -05:00
parent 3c6ecda8a1
commit a377c2ed27
3 changed files with 46 additions and 23 deletions

44
argv.go
View File

@ -27,19 +27,33 @@ type args struct {
Patch *PatchCmd `arg:"subcommand:patch" help:"make patchsets"`
Pull *PullCmd `arg:"subcommand:pull" help:"run 'git pull'"`
Show *ShowCmd `arg:"subcommand:show" help:"print out things"`
Dev *DevCmd `arg:"subcommand:dev" help:"features under development"`
All bool `arg:"--all" help:"git commit --all"`
Force bool `arg:"--force" help:"try to strong-arm things"`
Verbose bool `arg:"--verbose" help:"show more output"`
}
func (args) Examples() string {
var out string
out += "forge merge --all # merge all patches to devel & master\n"
out += "forge pull --force # 'git pull' on all repos\n"
out += "forge normal # the defaults for 'normal' forge distributed development\n"
return out
}
type EmptyCmd struct {
}
type testCmd string
type ShowCmd struct {
Dirty *EmptyCmd `arg:"subcommand:dirty" help:"show dirty git repos"`
Repo *RepoCmd `arg:"subcommand:repo" help:"print a table of the current repos"`
Repo *RepoCmd `arg:"subcommand:repos" 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"`
}
func (ShowCmd) Examples() string {
return "forge show dirty\nforge show repos --all"
}
type RepoCmd struct {
@ -52,9 +66,6 @@ type RepoCmd struct {
// ReadOnly bool `arg:"--readonly" help:"include read-only repos"`
}
type EmptyCmd struct {
}
type NormalCmd struct {
On *EmptyCmd `arg:"subcommand:on" help:"turn normal mode on"`
Off *EmptyCmd `arg:"subcommand:off" help:"turn normal mode off"`
@ -65,11 +76,22 @@ type CommitCmd struct {
All bool `arg:"--all" help:"git commit in all dirty repos"`
}
type testCmd string
type DevCmd struct {
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 CleanCmd struct {
// Verify *EmptyCmd `arg:"subcommand:verify" help:"rescan repo"`
// Repo string `arg:"--repo" help:"which repo to look at"`
Verify *EmptyCmd `arg:"subcommand:fix" help:"try to fix problems"`
Repo string `arg:"--repo" help:"which repo to look at"`
}
// matches
func (c CleanCmd) Match(partial string) []string {
// return repos here
return []string{"go.wit.com/apps/forge", "go.wit.com/apps/virtigo"}
}
type CleanDevelCmd struct {

View File

@ -35,6 +35,14 @@ func findRepos() *gitpb.Repos {
return findMine()
}
if argv.Show.Dirty != nil {
return me.forge.FindDirty()
}
if argv.Show.Repo == nil {
return findAll()
}
if argv.Show.Repo.All {
return findAll()
}
@ -51,10 +59,6 @@ func findRepos() *gitpb.Repos {
return findFavorites()
}
if argv.Show.Dirty != nil {
return me.forge.FindDirty()
}
if argv.Show.Repo.User {
return findUser()
}

13
main.go
View File

@ -41,18 +41,15 @@ func getVersion(repo *gitpb.Repo, name string) string {
func main() {
me = new(mainType)
me.myGui = prep.Gui() // prepares the GUI package for go-args
me.auto = prep.Bash3(&argv) // this line should be: prep.Bash(&argv)
// me.auto = prep.Bash3(argv.DoAutoComplete, &argv) // this line should be: prep.Bash(&argv)
// arg.MustParse(&argv) // these three lines are becoming terrible syntax
// me.auto = prep.MustParse(&argv) // try to make this work?
// the current os.Argv processing with go-args
me.myGui = prep.Gui() // adds the GUI package args support
me.auto = prep.Bash(&argv) // adds auto complete to go-args
// the current forge init process
me.forge = forgepb.Init() // init forge.pb
me.forge.ScanRepoDir() // looks for new dirs, checks existing repos for changes
// initialize patches
doPatchInit()
doPatchInit() // initialize patches
// first find the repos or gopaths to operate on
if argv.Config != nil {