From fd3b806b4a1f647103c7ecb417cf1ffced9c4cb1 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sun, 1 Dec 2024 12:53:46 -0600 Subject: [PATCH] add test app --- .gitignore | 1 + currentVersions.go | 3 +++ validate/Makefile | 20 +++++++++++++++++++ validate/argv.go | 41 +++++++++++++++++++++++++++++++++++++ validate/main.go | 50 ++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 115 insertions(+) create mode 100644 validate/Makefile create mode 100644 validate/argv.go create mode 100644 validate/main.go diff --git a/.gitignore b/.gitignore index 4bfdc3c..2489c5a 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ go.* *.pb.go scanGoSrc/scanGoSrc +validate/validate diff --git a/currentVersions.go b/currentVersions.go index c5c7395..4cbaa72 100644 --- a/currentVersions.go +++ b/currentVersions.go @@ -67,6 +67,9 @@ func (repo *Repo) GitDevelVersion() string { func (repo *Repo) GitUserVersion() string { bname := repo.GetUserBranchName() + if bname != "jcarr" { + panic("not jcarr bname =" + bname) + } v, err := repo.gitVersionByName(bname) if err == nil { return v diff --git a/validate/Makefile b/validate/Makefile new file mode 100644 index 0000000..24a62b6 --- /dev/null +++ b/validate/Makefile @@ -0,0 +1,20 @@ +VERSION = $(shell git describe --tags) +BUILDTIME = $(shell date +%Y.%m.%d) + +build: + reset + GO111MODULE=off go build \ + -ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}" + ./validate + +goimports: + goimports -w *.go + +prep: + go get -v -t -u + +run: + go run *.go + +clean: + -rm -f scanGoSrc diff --git a/validate/argv.go b/validate/argv.go new file mode 100644 index 0000000..b4150b4 --- /dev/null +++ b/validate/argv.go @@ -0,0 +1,41 @@ +package main + +import ( + "os" + + "go.wit.com/dev/alexflint/arg" +) + +var argv args + +type args struct { + List bool `arg:"--list" default:"false" help:"list repos in your config"` + SaveConfig bool `arg:"--save" default:"false" help:"save your config file at the end"` + 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/validate/main.go b/validate/main.go new file mode 100644 index 0000000..da709e0 --- /dev/null +++ b/validate/main.go @@ -0,0 +1,50 @@ +package main + +import ( + "os" + + "go.wit.com/dev/alexflint/arg" + "go.wit.com/gui" + "go.wit.com/lib/gui/repolist" + "go.wit.com/lib/protobuf/forgepb" + "go.wit.com/lib/protobuf/gitpb" + "go.wit.com/log" +) + +// sent via ldflags +var VERSION string + +var pp *arg.Parser +var forge *forgepb.Forge +var myGui *gui.Node +var rv *repolist.RepoList +var argvRepo *gitpb.Repo + +func main() { + pp = arg.MustParse(&argv) + + // load the ~/.config/forge/ config + forge = forgepb.Init() + // forge.ConfigPrintTable() + os.Setenv("REPO_WORK_PATH", forge.GetGoSrc()) + + myGui = gui.New() + myGui.Default() + + repos := forge.Repos.SortByGoPath() + for repos.Scan() { + repo := repos.Next() + forge.VerifyBranchNames(repo) + fullpath := repo.GetFullPath() + mName := repo.GetMasterBranchName() + dName := repo.GetDevelBranchName() + uName := repo.GetUserBranchName() + log.Printf("repo: %-60s %-8s %-8s %-8s\n", fullpath, mName, dName, uName) + } + + if argv.SaveConfig { + forge.Repos.ConfigSave() + } + + os.Exit(0) +}