summaryrefslogtreecommitdiff
path: root/forgeConfig
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-01-06 21:53:20 -0600
committerJeff Carr <[email protected]>2025-01-06 21:53:20 -0600
commit89d034c3101c0ac2192b3c1278d78cebff889543 (patch)
treebdaa22063a57f8e84b8c21555a3b716513b7a73d /forgeConfig
parent98b0d445bc513c5439421d1ec0d32874fc1350f9 (diff)
merged with forge. unbelievable. thanks Alex Flint!v0.0.19
Diffstat (limited to 'forgeConfig')
-rw-r--r--forgeConfig/Makefile48
-rw-r--r--forgeConfig/argv.go53
-rw-r--r--forgeConfig/main.go92
3 files changed, 0 insertions, 193 deletions
diff --git a/forgeConfig/Makefile b/forgeConfig/Makefile
deleted file mode 100644
index b918330..0000000
--- a/forgeConfig/Makefile
+++ /dev/null
@@ -1,48 +0,0 @@
-VERSION = $(shell git describe --tags)
-BUILDTIME = $(shell date +%Y.%m.%d)
-
-build: goimports
- GO111MODULE=off go build \
- -ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}"
-
-test2:
- ./forgeConfig
- FORGE_HOME=/tmp/forge ./forgeConfig
- FORGE_HOME=/tmp/forge ./forgeConfig --list
-
-install: goimports
- GO111MODULE=off go install \
- -ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}"
-
-test:
- ./forgeConfig --list
- ./forgeConfig --add --gopath 'go.wit.com/apps/foo'
- ./forgeConfig --add --gopath 'go.wit.com/apps/foowrite' --writable
- ./forgeConfig --add --gopath 'gitea.wit.com' --directory
- ./forgeConfig --add --gopath 'git.wit.org' --directory
- ./forgeConfig --delete --gopath 'go.wit.com/apps/helloworld'
- ./forgeConfig --list
-
-list:
- ./forgeConfig --list
-
-add:
- ./forgeConfig --add --name 'foo' --gopath 'go.wit.com/apps/foo'
-
-update:
- ./forgeConfig --update --name 'foo' --gopath 'more stuff but not memory corruption?'
-
-corruptMemory:
- ./forgeConfig --update --name 'foo' --gopath 'blah'
-
-goimports:
- goimports -w *.go
-
-prep:
- go get -v -t -u
-
-run:
- go run *.go
-
-clean:
- -rm -f forgeConfig
diff --git a/forgeConfig/argv.go b/forgeConfig/argv.go
deleted file mode 100644
index a39509f..0000000
--- a/forgeConfig/argv.go
+++ /dev/null
@@ -1,53 +0,0 @@
-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"`
- 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"`
-}
-
-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/forgeConfig/main.go b/forgeConfig/main.go
deleted file mode 100644
index d6fabba..0000000
--- a/forgeConfig/main.go
+++ /dev/null
@@ -1,92 +0,0 @@
-package main
-
-import (
- "os"
-
- "go.wit.com/lib/protobuf/forgepb"
- "go.wit.com/log"
-)
-
-// sent via ldflags
-var VERSION string
-
-func main() {
- var f *forgepb.Forge
- f = forgepb.Init()
-
- if argv.List {
- f.ConfigPrintTable()
- /*
- loop := f.Config.SortByGoPath() // get the list of forge configs
- for loop.Scan() {
- r := loop.Next()
- log.Info("repo:", r.GoPath)
- }
- */
- os.Exit(0)
- }
-
- // try to delete, then save config and exit
- if argv.Delete {
- if deleteGoPath(f, argv.GoPath) {
- log.Info("deleted", argv.GoPath, "ok")
- f.ConfigSave()
- os.Exit(0)
- }
- log.Info("deleted", argv.GoPath, "did not exist. did nothing")
- os.Exit(0)
- }
-
- // try to update, then save config and exit
- if argv.Update {
- /*
- if f.UpdateGoPath(argv.Name, argv.GoPath) {
- // save updated config file
- repos.ConfigSave()
- }
- */
- os.Exit(0)
- }
-
- // try to add, then save config and exit
- if argv.Add {
- log.Info("going to add a new repo", argv.GoPath)
- deleteGoPath(f, argv.GoPath)
- new1 := forgepb.ForgeConfig{
- GoPath: argv.GoPath,
- Writable: argv.Writable,
- ReadOnly: argv.ReadOnly,
- Private: argv.Private,
- Directory: argv.Directory,
- Favorite: argv.Favorite,
- Interesting: argv.Interesting,
- MasterBranchName: argv.Master,
- DevelBranchName: argv.Devel,
- UserBranchName: argv.User,
- }
-
- if f.Config.Append(&new1) {
- log.Info("added", new1.GoPath, "ok")
- } else {
- log.Info("added", new1.GoPath, "failed")
- os.Exit(-1)
- }
- f.ConfigSave()
- os.Exit(0)
- }
-
-}
-
-func deleteGoPath(f *forgepb.Forge, gopath string) bool {
- var deleted bool = false
- for {
- if f.Config.DeleteByGoPath(gopath) {
- log.Info("deleted ok", gopath)
- deleted = true
- } else {
- log.Info("did not delete", gopath)
- break
- }
- }
- return deleted
-}