diff options
Diffstat (limited to 'argv.go')
| -rw-r--r-- | argv.go | 142 |
1 files changed, 66 insertions, 76 deletions
@@ -4,10 +4,10 @@ package main import ( - "fmt" "os" "go.wit.com/lib/gui/prep" + "go.wit.com/log" ) /* @@ -17,27 +17,36 @@ import ( var argv args type args struct { - Help *EmptyCmd `arg:"subcommand:help" help:"New to forge? This is for you.'"` - Checkout *CheckoutCmd `arg:"subcommand:checkout" help:"switch branches using 'git checkout'"` - Clean *CleanCmd `arg:"subcommand:clean" help:"start over at the beginning"` - Commit *CommitCmd `arg:"subcommand:commit" help:"'git commit' but errors out if on wrong branch"` - Config *ConfigCmd `arg:"subcommand:config" help:"show your .config/forge/ settings"` - Dirty *DirtyCmd `arg:"subcommand:dirty" help:"show dirty git repos"` - GitFetch *FindCmd `arg:"subcommand:fetch" help:"run 'git fetch master'"` - Gui *EmptyCmd `arg:"subcommand:gui" help:"open the gui"` - List *FindCmd `arg:"subcommand:list" help:"print a table of the current repos"` - Merge *MergeCmd `arg:"subcommand:merge" help:"merge branches"` - Normal *NormalCmd `arg:"subcommand:normal" help:"set every repo to the default state for software development"` - Patch *PatchCmd `arg:"subcommand:patch" help:"make patchsets"` - Pull *PullCmd `arg:"subcommand:pull" help:"run 'git pull'"` - Tag *TagCmd `arg:"subcommand:tag" help:"manage git tags"` - URL string `arg:"--connect" help:"forge url"` - All bool `arg:"--all" help:"git commit --all"` - 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"` - Force bool `arg:"--force" help:"try to strong arm things"` - Verbose bool `arg:"--verbose" help:"show more output"` + Checkout *CheckoutCmd `arg:"subcommand:checkout" help:"switch branches using 'git checkout'"` + Clean *CleanCmd `arg:"subcommand:clean" help:"start over at the beginning"` + Commit *CommitCmd `arg:"subcommand:commit" help:"'git commit' but errors out if on wrong branch"` + Config *ConfigCmd `arg:"subcommand:config" help:"show your .config/forge/ settings"` + Gui *EmptyCmd `arg:"subcommand:gui" help:"open the gui"` + Merge *MergeCmd `arg:"subcommand:merge" help:"merge branches"` + Normal *NormalCmd `arg:"subcommand:normal" help:"set every repo to the default state for software development"` + 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"` + 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"` +} + +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"` + 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:"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"` } type EmptyCmd struct { @@ -49,7 +58,8 @@ type NormalCmd struct { } type CommitCmd struct { - Submit bool `arg:"--submit" default:"true" help:"submit the patches to forge"` + // Submit bool `arg:"--submit" default:"true" help:"submit the patches to forge"` + All bool `arg:"--all" default:"true" help:"git commit in all dirty repos"` } type testCmd string @@ -103,45 +113,49 @@ type ConfigAddCmd struct { User string `arg:"--user" help:"the git user branch name"` } -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 CheckoutCmd struct { - 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"` + 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 *FindCmd `arg:"subcommand:devel" help:"merge user to devel"` - Master *FindCmd `arg:"subcommand:master" help:"merge devel to master"` + 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 DirtyCmd struct { -} - -type FindCmd 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"` - Private bool `arg:"--private" help:"your private repos from your .config/forge/"` - Dirty bool `arg:"--dirty" help:"only use dirty git repos"` - 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"` +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 } +// keep this small +func doHelp() { + log.Info("") + log.Info("forge -h : to see the available options") + log.Info("forge --bash : will create a bash autocomplete file") + log.Info("forge : with no arguements, forge tries to load a GO GUI plugin") + log.Info(" : there are two GUI plugins. terminal & GTK") + log.Info("") + log.Info("forge list : shows a table of all your repos") + log.Info("forge checkout : checks out all your repos to the same branch") + log.Info(" : the default is your user branch") + log.Info("forge clean : reverts all repos to the master branch") + log.Info("forge dirty : show all repos git reports as dirty") + log.Info("") +} + func (a args) Description() string { + // doHelp() + return ` forge -- a tool to manage lots of git repos. forge includes a GUI and TUI. @@ -152,37 +166,13 @@ 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 "checkout": - pb.Autocomplete2("devel master user") - case "clean": - pb.Autocomplete2("") - case "commit": - pb.Autocomplete2("--all") - case "config": - fmt.Println("add fix list") - case "dirty": - fmt.Println("") - case "gui": - fmt.Println("") - case "--gui": - pb.Autocomplete2("andlabs gocui") - case "list": - pb.Autocomplete2("--mine --favorites --dirty") - case "merge": - pb.Autocomplete2("devel master --all") - case "normal": - pb.Autocomplete2("on off") - case "pull": - pb.Autocomplete2("--force check") - case "patch": - fmt.Println("check get list repos submit show") - case "tag": - fmt.Println("list --delete clean") + case "show": + pb.SubCommand(pb.Cmd) default: if pb.Cmd == "" { - pb.Autocomplete2("help list checkout clean commit dirty fetch gui normal merge patch pull tag --gui") + pb.Autocomplete2("checkout clean commit normal merge show") } else { - pb.Autocomplete2("list checkout clean commit dirty normal merge tag") + pb.SubCommand(pb.Cmd) } } os.Exit(0) |
