summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-03-07 16:45:49 -0600
committerJeff Carr <[email protected]>2024-03-07 16:45:49 -0600
commit57c61847c02e9b2f3c2e36f9c77c9dcb8da01b8c (patch)
tree029fd4b5635c09d10be5dbb4ba2eb7b1c24fda58
parentbf83739801829107c0245e738d6c4360b021504e (diff)
make a .git repo
-rw-r--r--Makefile7
-rw-r--r--args.go19
-rw-r--r--argv.go24
-rw-r--r--go.work57
-rw-r--r--main.go83
-rw-r--r--readWorkFile.go8
6 files changed, 86 insertions, 112 deletions
diff --git a/Makefile b/Makefile
index e997ae0..abbc63e 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,7 @@
+VERSION = $(shell git describe --tags)
+
run: build
- ./go-clone --repo github.com/rclone/rclone
+ ./go-clone github.com/rclone/rclone
vet:
@GO111MODULE=off go vet
@@ -9,7 +11,8 @@ no-gui: build
./go-clone --no-gui
build:
- GO111MODULE="off" go build -v
+ # GO111MODULE=off go build -v -ldflags "-X main.VERSION=${VERSION}" -ldflags "-X main.GUIVERSION=${VERSION}"
+ GO111MODULE=off go build -v -ldflags "-X main.GUIVERSION=${VERSION}"
install:
GO111MODULE="off" go install -v
diff --git a/args.go b/args.go
deleted file mode 100644
index 3ff5743..0000000
--- a/args.go
+++ /dev/null
@@ -1,19 +0,0 @@
-package main
-
-/*
- this parses the command line arguements
-
- this enables command line options from other packages like 'gui' and 'log'
-*/
-
-import (
- "go.wit.com/dev/alexflint/arg"
-)
-
-var args struct {
- Repo string `arg:"--repo" help:"go path for the repo"`
-}
-
-func init() {
- arg.MustParse(&args)
-}
diff --git a/argv.go b/argv.go
new file mode 100644
index 0000000..be670dd
--- /dev/null
+++ b/argv.go
@@ -0,0 +1,24 @@
+package main
+
+/*
+ this parses the command line arguements
+
+ this enables command line options from other packages like 'gui' and 'log'
+*/
+
+type args struct {
+ Repo string `arg:"positional" help:"go import path"`
+ Work bool `arg:"--work" help:"make a work directory"`
+}
+
+func (args) Description() string {
+ return `
+Example usage: "go-clone go.wit.com/apps/go-clone"
+
+This will pull down the go sources and
+the repositories in the go.sum file using git clone`
+}
+
+func (args) Version() string {
+ return "go-clone " + VERSION
+}
diff --git a/go.work b/go.work
deleted file mode 100644
index ee399ae..0000000
--- a/go.work
+++ /dev/null
@@ -1,57 +0,0 @@
-go 1.22.0
-
-use (
- git.wit.org/jcarr/jcarrgitpull
- github.com/Showmax/go-fqdn
- github.com/alexflint/go-arg
- github.com/alexflint/go-scalar
- github.com/awesome-gocui/gocui
- github.com/coreos/go-systemd
- github.com/gdamore/encoding
- github.com/gdamore/tcell
- github.com/google/subcommands
- github.com/gorilla/websocket
- github.com/lucasb-eyer/go-colorful
- github.com/mattn/go-runewidth
- github.com/miekg/dns
- github.com/rivo/uniseg
- github.com/sirupsen/logrus
- github.com/skx/simple-vpn
- go.wit.com/apps/autotypist
- go.wit.com/apps/control-panel-cloudflare
- go.wit.com/apps/control-panel-dns
- go.wit.com/apps/control-panel-vpn
- go.wit.com/apps/forge
- go.wit.com/apps/go-deb
- go.wit.com/apps/go-clone
- go.wit.com/apps/go-gui-toolkits
- go.wit.com/apps/go.wit.com
- go.wit.com/apps/guireleaser
- go.wit.com/apps/helloworld
- go.wit.com/apps/wit-packager
- go.wit.com/dev/alexflint/arg
- go.wit.com/dev/alexflint/scalar
- go.wit.com/dev/andlabs/ui
- go.wit.com/dev/davecgh/spew
- go.wit.com/gui
- go.wit.com/lib/gadgets
- go.wit.com/lib/gui/cloudflare
- go.wit.com/lib/gui/gowit
- go.wit.com/lib/gui/linuxstatus
- go.wit.com/lib/gui/logsettings
- go.wit.com/lib/gui/repolist
- go.wit.com/lib/gui/repostatus
- go.wit.com/lib/gui/shell
- go.wit.com/log
- go.wit.com/toolkits/andlabs
- go.wit.com/toolkits/debian
- go.wit.com/toolkits/gocui
- go.wit.com/toolkits/nocui
- go.wit.com/toolkits/tree
- go.wit.com/widget
- golang.org/x/crypto
- golang.org/x/net
- golang.org/x/sys
- golang.org/x/term
- golang.org/x/text
-)
diff --git a/main.go b/main.go
index 1d462e2..e7a97f8 100644
--- a/main.go
+++ b/main.go
@@ -1,51 +1,66 @@
package main
import (
- "os"
- "path/filepath"
-
+ "go.wit.com/dev/alexflint/arg"
+ "go.wit.com/gui"
+ "go.wit.com/lib/gui/repolist"
"go.wit.com/lib/gui/shell"
"go.wit.com/log"
)
-// This is the beginning of the binary tree of GUI widgets
-// var myGui *gui.Node
+var VERSION string
-// this is a basic window. the user can open and close it
-// var basicWindow *gadgets.BasicWindow
+var rv *repolist.RepoList
func main() {
- if args.Repo == "" {
- log.Info("You need to tell me what repo you want to work on")
- log.Info("")
- log.Info("go-clone --repo go.wit.com/apps/helloworld")
- os.Exit(0)
+
+ var myargs args
+ // tmp := arg.MustParse(&myargs)
+ arg.MustParse(&myargs)
+
+ if myargs.Work {
+ shell.Mkdir("work")
+ } else {
+ // filepath := filepath.Join("/home/jcarr/go/src")
+ // os.Chdir(filepath)
}
- /*
- if args.Gui == "" {
- myGui = gui.New()
- myGui.Default()
- }
- */
+ // if myargs.Repo == "" {
+ // // tmp.WriteHelp(os.Stdout)
+ // // fmt.Println("hello world")
+ // tmp := myargs.Description()
+ // fmt.Println(tmp)
+ // os.Exit(0)
+ // }
- filepath := filepath.Join("/home/jcarr/go/src", args.Repo)
- os.Chdir(filepath)
+ b := gui.RawBox()
+ rv = repolist.AutotypistView(b)
- shell.TestTerminalColor()
+ // shell.TestTerminalColor()
readControlFile()
- os.Exit(0)
- /*
- // run the debugger if triggered from the commandline
- if debugger.ArgDebug() {
- go func() {
- log.Sleep(2)
- debugger.DebugWindow()
- }()
- }
+ clone(myargs.Repo)
+ rv.NewRepo(myargs.Repo)
+
+ rv.NewRepo("go.wit.com/apps/helloworld")
+
+ for _, repo := range rv.AllRepos() {
+ log.Info("found repo", repo.GoPath(), repo.Status.Path())
+ }
- // go will sit here until the window exits
- gui.Watchdog()
- os.Exit(0)
- */
+ rv.Watchdog(func() {
+ log.Info("watchdog")
+ })
}
+
+func clone(path string) {
+ shell.RunPath([]string{"git", "clone", path})
+}
+
+func findWorkDir() {
+ if myargs.Work {
+ shell.Mkdir("work")
+ shell.Mkdir("work")
+ }
+ // filepath := filepath.Join("/home/jcarr/go/src")
+ // os.Chdir(filepath)
+
diff --git a/readWorkFile.go b/readWorkFile.go
index 87e31fe..e11ad90 100644
--- a/readWorkFile.go
+++ b/readWorkFile.go
@@ -5,9 +5,16 @@ import (
"os"
"strings"
+ "go.wit.com/lib/gui/shell"
"go.wit.com/log"
)
+func addDir(d string) {
+ if shell.IsDir(d) {
+ rv.NewRepo(d)
+ }
+}
+
func readControlFile() error {
file, err := os.Open("go.work")
if err != nil {
@@ -29,6 +36,7 @@ func readControlFile() error {
continue
}
log.Info(line)
+ addDir(line)
}
if err := scanner.Err(); err != nil {