more argv examples

This commit is contained in:
Jeff Carr 2025-01-06 21:29:19 -06:00
parent be98039d69
commit 7b1392bae9
1 changed files with 27 additions and 16 deletions

43
argv.go
View File

@ -6,11 +6,25 @@ import (
)
/*
this parses the command line arguements
this parses the command line arguements using alex flint's go-arg
*/
var argv args
type args struct {
Checkout *CheckoutCmd `arg:"subcommand:checkout" help:"switch git branches"`
Config *ConfigCmd `arg:"subcommand:config" help:"show your .config/forge/ settings"`
Dirty *EmptyCmd `arg:"subcommand:dirty" help:"check if your git repos are dirty"`
GitReset *EmptyCmd `arg:"subcommand:hard-reset" help:"hard reset your user git branches"`
List *FindCmd `arg:"subcommand:list" help:"just show a table of the current state"`
Patch *PatchCmd `arg:"subcommand:patch" help:"examine and make patch sets"`
GitPull *FindCmd `arg:"subcommand:pull" help:"run 'git pull'"`
Rescan *EmptyCmd `arg:"subcommand:rescan" help:"recreate the git protobuf repos.pb file"`
URL string `arg:"--connect" help:"gowebd url"`
Bash bool `arg:"--bash" help:"generate bash completion"`
BashAuto []string `arg:"--auto-complete" help:"does the actual autocompletion"`
}
type EmptyCmd struct {
}
@ -20,7 +34,8 @@ type PatchCmd struct {
}
type ConfigAddCmd struct {
GoPath string `arg:"--gopath" help:"gopath of the repo"`
Path string `arg:"--path" help:"absolute path of the git repo"`
GoPath string `arg:"--gopath" help:"GO path of the git repo"`
Directory bool `arg:"--directory" default:"false" help:"repo is a directory to match against"`
ReadOnly bool `arg:"--readonly" default:"false" help:"repo is readonly"`
Writable bool `arg:"--writable" default:"false" help:"repo is writable"`
@ -55,20 +70,6 @@ type FindCmd struct {
// ReadOnly bool `arg:"--readonly" help:"include read-only repos"`
}
type args struct {
Checkout *CheckoutCmd `arg:"subcommand:checkout" help:"switch git branches"`
Config *ConfigCmd `arg:"subcommand:config" help:"show your .config/forge/ settings"`
Dirty *EmptyCmd `arg:"subcommand:dirty" help:"check if your git repos are dirty"`
GitReset *EmptyCmd `arg:"subcommand:hard-reset" help:"hard reset your user git branches"`
List *FindCmd `arg:"subcommand:list" help:"just show a table of the current state"`
Patch *PatchCmd `arg:"subcommand:patch" help:"examine and make patch sets"`
GitPull *FindCmd `arg:"subcommand:pull" help:"run 'git pull'"`
Rescan *EmptyCmd `arg:"subcommand:rescan" help:"recreate the git protobuf repos.pb file"`
URL string `arg:"--connect" help:"gowebd url"`
Bash bool `arg:"--bash" help:"generate bash completion"`
BashAuto []string `arg:"--auto-complete" help:"does the actual autocompletion"`
}
func (args) Version() string {
return "forge " + VERSION + " Built on " + BUILDTIME
}
@ -77,6 +78,10 @@ func (a args) Description() string {
return `
forge -- in the spirit of things like sourceforge
This supports GO projects so far.
It will work from ~/go/src or where your go.work file is.
Since I mostly use ~/go/src, that has been tested more.
Examples:
forge # opens the GUI
forge list # show every repo state
@ -84,6 +89,12 @@ Examples:
forge pull # run 'git pull' in every repo
forge checkout # switch git branches
forge config add --private --path /opt/bob # add a private repo /opt/bob
forge config add --directory --writable \
--gopath 'go.wit.com/user/bob' # directory contains r/w repos
forge config add --private --writeable \
--gopath 'go.wit.com/user/bob/work' # a GO repo that can not be published
`
}