diff options
| author | Jeff Carr <[email protected]> | 2024-12-01 19:27:30 -0600 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2024-12-01 19:27:30 -0600 |
| commit | 9d95b189135422a720cb00f8b0ca8546e7fdc9b5 (patch) | |
| tree | 34299ad83167152bf4681b4264751b5c4f9cdf50 /scanGoSrc | |
Diffstat (limited to 'scanGoSrc')
| -rw-r--r-- | scanGoSrc/Makefile | 25 | ||||
| -rw-r--r-- | scanGoSrc/argv.go | 50 | ||||
| -rw-r--r-- | scanGoSrc/main.go | 54 |
3 files changed, 129 insertions, 0 deletions
diff --git a/scanGoSrc/Makefile b/scanGoSrc/Makefile new file mode 100644 index 0000000..eeaa73f --- /dev/null +++ b/scanGoSrc/Makefile @@ -0,0 +1,25 @@ +VERSION = $(shell git describe --tags) +BUILDTIME = $(shell date +%Y.%m.%d) + +build: + GO111MODULE=off go build \ + -ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}" + +test: + FORGE_HOME=/tmp/forge ./scanGoSrc + +install: + GO111MODULE=off go install \ + -ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}" + +goimports: + goimports -w *.go + +prep: + go get -v -t -u + +run: + go run *.go + +clean: + -rm -f scanGoSrc diff --git a/scanGoSrc/argv.go b/scanGoSrc/argv.go new file mode 100644 index 0000000..635989f --- /dev/null +++ b/scanGoSrc/argv.go @@ -0,0 +1,50 @@ +package main + +import ( + "os" + + "go.wit.com/dev/alexflint/arg" +) + +var argv args + +type args struct { + ConfigDir string `arg:"env:FORGE_HOME" help:"defaults to ~/.config/forge/"` + List bool `arg:"--list" default:"false" help:"list repos in your config"` + Add bool `arg:"--add" default:"false" help:"add a new repo"` + Delete bool `arg:"--delete" default:"false" help:"delete a repo"` + Update bool `arg:"--update" default:"false" help:"update a repo"` + 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"` +} + +func (a args) Description() string { + return ` + forgeConfig -- add entries to your config files + +This is just example protobuf code to test forgepb is working +but it could be used to automagically create a config file too. + +If you need to change your config file, just edit the forge.text or forge.json +files then remove the forge.pb and ConfigLoad() will attempt to load those files instead +` +} + +func (args) Version() string { + return "virtigo " + VERSION +} + +func init() { + var pp *arg.Parser + pp = arg.MustParse(&argv) + + if pp == nil { + pp.WriteHelp(os.Stdout) + os.Exit(0) + } +} diff --git a/scanGoSrc/main.go b/scanGoSrc/main.go new file mode 100644 index 0000000..f59ea77 --- /dev/null +++ b/scanGoSrc/main.go @@ -0,0 +1,54 @@ +package main + +import ( + "os" + + "go.wit.com/lib/protobuf/gitpb" + "go.wit.com/log" +) + +// sent via ldflags +var VERSION string + +func main() { + var repos *gitpb.Repos + repos = new(gitpb.Repos) + + newr, err := repos.NewGoPath("/home/jcarr/go/src", "go.wit.com/apps/wit-package") + if err != nil { + log.Info("init failed", err) + panic("crapnuts") + } else { + log.Info("init worked for", newr.GoPath) + } + + newr, err = repos.NewGoPath("/home/jcarr/go/src", "go.wit.com/apps/notathing") + if err != nil { + log.Info("init failed correctly:", err) + } else { + log.Info("init should have failed for", newr.GoPath) + panic("crapnuts") + } + + /* + log.Info(forgepb.RepoHeader()) + loop := repos.SortByPath() // get the list of repos + for loop.Scan() { + r := loop.Repo() + log.Info("repo:", r.GoPath) + } + */ + /* + log.Info("going to add a new repo", argv.GoPath) + new1 := forgepb.Repo{ + GoPath: argv.GoPath, + Writable: argv.Writable, + ReadOnly: argv.ReadOnly, + Private: argv.Private, + Directory: argv.Directory, + Favorite: argv.Favorite, + Interesting: argv.Interesting, + } + */ + os.Exit(0) +} |
