cleaner code
This commit is contained in:
parent
4d1d02cc1a
commit
2ffc60a5d4
23
argv.go
23
argv.go
|
@ -19,12 +19,25 @@ type PatchCmd struct {
|
||||||
Show *EmptyCmd `arg:"subcommand:show" help:"show a specific patch"`
|
Show *EmptyCmd `arg:"subcommand:show" help:"show a specific patch"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ConfigAddCmd struct {
|
||||||
|
GoPath string `arg:"--gopath" help:"gopath of the 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"`
|
||||||
|
Favorite bool `arg:"--favorite" default:"false" help:"forge will always go-clone or git clone this"`
|
||||||
|
Private bool `arg:"--private" default:"false" help:"repo can not be published"`
|
||||||
|
Interesting bool `arg:"--interesting" default:"false" help:"something you decided was cool"`
|
||||||
|
Master string `arg:"--master" help:"the git 'master' or 'main' branch name"`
|
||||||
|
Devel string `arg:"--devel" help:"the git devel branch name"`
|
||||||
|
User string `arg:"--user" help:"the git user branch name"`
|
||||||
|
}
|
||||||
|
|
||||||
type ConfigCmd struct {
|
type ConfigCmd struct {
|
||||||
Add *EmptyCmd `arg:"subcommand:add" help:"add a config setting"`
|
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"`
|
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"`
|
List *EmptyCmd `arg:"subcommand:list" help:"list your config settings"`
|
||||||
Delete string `arg:"--delete" help:"delete this repo"`
|
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)"`
|
Register string `arg:"--register" help:"register your git URL (foo.com/mystuff) or (github.com/foo/bar)"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type CheckoutCmd struct {
|
type CheckoutCmd struct {
|
||||||
|
|
|
@ -1,54 +0,0 @@
|
||||||
package main
|
|
||||||
|
|
||||||
import "go.wit.com/log"
|
|
||||||
|
|
||||||
// retuns true if nothing was done
|
|
||||||
func findConfig(fargv *FindCmd) {
|
|
||||||
if fargv == nil {
|
|
||||||
findConfigAll()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if fargv.Mine {
|
|
||||||
findConfigMine()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if fargv.All {
|
|
||||||
findConfigAll()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
findConfigAll()
|
|
||||||
}
|
|
||||||
|
|
||||||
// finds config repos that are writable
|
|
||||||
func findConfigMine() {
|
|
||||||
all := me.forge.Config.SortByGoPath()
|
|
||||||
for all.Scan() {
|
|
||||||
r := all.Next()
|
|
||||||
gopath := r.GoPath
|
|
||||||
if r.GetDirectory() {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if me.forge.Config.IsWritable(gopath) {
|
|
||||||
log.Info("mine:", gopath)
|
|
||||||
me.foundPaths = append(me.foundPaths, gopath)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// get everything in your config
|
|
||||||
func findConfigAll() {
|
|
||||||
all := me.forge.Config.SortByGoPath()
|
|
||||||
for all.Scan() {
|
|
||||||
r := all.Next()
|
|
||||||
gopath := r.GoPath
|
|
||||||
if r.GetDirectory() {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if me.forge.Config.IsWritable(gopath) {
|
|
||||||
log.Info("mine:", gopath)
|
|
||||||
me.foundPaths = append(me.foundPaths, gopath)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue