summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-09-11 03:27:49 -0500
committerJeff Carr <[email protected]>2025-09-11 03:27:49 -0500
commitd19f4a8911dc6b6baca272d6ee16b11eb6aea1a9 (patch)
tree71a62e85ff8657322410b36f82590801a9466127
parent54811a5bc1906f5b20e9673621d54ffff9570392 (diff)
new forge init()
-rw-r--r--Makefile4
-rw-r--r--argv.go20
-rw-r--r--config.go19
-rw-r--r--main.go21
4 files changed, 50 insertions, 14 deletions
diff --git a/Makefile b/Makefile
index a5beb23..4a4ed25 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
VERSION = $(shell git describe --tags)
BUILDTIME = $(shell date +%Y.%m.%d_%H%M)
-run: install build-darwin build-darwin-arm64 build-windows
+run: install
go-clone --version
vet:
@@ -51,7 +51,7 @@ nocui: build
clean:
rm -f go.*
- -rm go-clone
+ -rm go-clone*
go-mod-clean purge
# this will test the golang.org/x -> googlesource override
diff --git a/argv.go b/argv.go
index 158aa23..076fc2b 100644
--- a/argv.go
+++ b/argv.go
@@ -1,5 +1,10 @@
package main
+import (
+ "fmt"
+ "os"
+)
+
/*
this parses the command line arguements
@@ -31,3 +36,18 @@ Examples:
go-clone go.wit.com/apps/go-clone # 'git clone' go-clone
`
}
+
+func (a args) DoAutoComplete(argv []string) {
+ switch argv[0] {
+ case "checkout":
+ fmt.Println("user devel master ")
+ case "--recursive":
+ fmt.Println("true false")
+ default:
+ if argv[0] == ARGNAME {
+ // list the subcommands here
+ fmt.Println("--dry-run --recursive --work")
+ }
+ }
+ os.Exit(0)
+}
diff --git a/config.go b/config.go
new file mode 100644
index 0000000..24f047a
--- /dev/null
+++ b/config.go
@@ -0,0 +1,19 @@
+package main
+
+import (
+ "go.wit.com/lib/config"
+ "go.wit.com/lib/protobuf/forgepb"
+ "go.wit.com/log"
+)
+
+// sent via -ldflags
+
+func configInit() *forgepb.ForgeConfigs {
+ configs := new(forgepb.ForgeConfigs)
+ err := config.ConfigLoad(configs, "forge", "forge")
+ if err != nil {
+ log.Info("This tool requires your repos be scanned by forge first")
+ badExit(err)
+ }
+ return configs
+}
diff --git a/main.go b/main.go
index 1c9d310..0ff1472 100644
--- a/main.go
+++ b/main.go
@@ -4,6 +4,7 @@ import (
"os"
"go.wit.com/dev/alexflint/arg"
+ "go.wit.com/lib/gui/prep"
"go.wit.com/lib/protobuf/forgepb"
"go.wit.com/lib/protobuf/gitpb"
"go.wit.com/log"
@@ -13,6 +14,8 @@ import (
var VERSION string
var BUILDTIME string
+var ARGNAME string = "go-clone"
+
var pp *arg.Parser
var forge *forgepb.Forge
@@ -20,20 +23,14 @@ var workingRepo *gitpb.Repo
func main() {
log.Info("go-clone version", VERSION, "built on", BUILDTIME)
- pp = arg.MustParse(&argv)
+ // command line parsing & handling
+ prep.Bash(ARGNAME, argv.DoAutoComplete) // todo: make this: prep.Bash(argv)
- // for very new users or users unfamilar with the command line, this may help them
- if argv.Repo == "help" || argv.Repo == "?" {
- pp.WriteHelp(os.Stdout)
- os.Exit(0)
- }
- if argv.Repo == "version" {
- log.Info(argv.Version())
- os.Exit(0)
- }
+ pp = arg.MustParse(&argv)
- // this package helps scan git repos
- forge = forgepb.Init()
+ // read in forge info
+ cfg := configInit()
+ forge = forgepb.InitFromConfig(cfg)
var err error
// attempt to clone, returns *gitpb.Repo