make a .git repo

This commit is contained in:
Jeff Carr 2024-03-07 16:45:49 -06:00
parent bf83739801
commit 57c61847c0
6 changed files with 86 additions and 112 deletions

View File

@ -1,5 +1,7 @@
VERSION = $(shell git describe --tags)
run: build run: build
./go-clone --repo github.com/rclone/rclone ./go-clone github.com/rclone/rclone
vet: vet:
@GO111MODULE=off go vet @GO111MODULE=off go vet
@ -9,7 +11,8 @@ no-gui: build
./go-clone --no-gui ./go-clone --no-gui
build: 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: install:
GO111MODULE="off" go install -v GO111MODULE="off" go install -v

19
args.go
View File

@ -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)
}

24
argv.go Normal file
View File

@ -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
}

57
go.work
View File

@ -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
)

83
main.go
View File

@ -1,51 +1,66 @@
package main package main
import ( import (
"os" "go.wit.com/dev/alexflint/arg"
"path/filepath" "go.wit.com/gui"
"go.wit.com/lib/gui/repolist"
"go.wit.com/lib/gui/shell" "go.wit.com/lib/gui/shell"
"go.wit.com/log" "go.wit.com/log"
) )
// This is the beginning of the binary tree of GUI widgets var VERSION string
// var myGui *gui.Node
// this is a basic window. the user can open and close it var rv *repolist.RepoList
// var basicWindow *gadgets.BasicWindow
func main() { func main() {
if args.Repo == "" {
log.Info("You need to tell me what repo you want to work on") var myargs args
log.Info("") // tmp := arg.MustParse(&myargs)
log.Info("go-clone --repo go.wit.com/apps/helloworld") arg.MustParse(&myargs)
os.Exit(0)
if myargs.Work {
shell.Mkdir("work")
} else {
// filepath := filepath.Join("/home/jcarr/go/src")
// os.Chdir(filepath)
} }
/* // if myargs.Repo == "" {
if args.Gui == "" { // // tmp.WriteHelp(os.Stdout)
myGui = gui.New() // // fmt.Println("hello world")
myGui.Default() // tmp := myargs.Description()
} // fmt.Println(tmp)
*/ // os.Exit(0)
// }
filepath := filepath.Join("/home/jcarr/go/src", args.Repo) b := gui.RawBox()
os.Chdir(filepath) rv = repolist.AutotypistView(b)
shell.TestTerminalColor() // shell.TestTerminalColor()
readControlFile() readControlFile()
os.Exit(0)
/* clone(myargs.Repo)
// run the debugger if triggered from the commandline rv.NewRepo(myargs.Repo)
if debugger.ArgDebug() {
go func() {
log.Sleep(2)
debugger.DebugWindow()
}()
}
// go will sit here until the window exits rv.NewRepo("go.wit.com/apps/helloworld")
gui.Watchdog()
os.Exit(0) for _, repo := range rv.AllRepos() {
*/ log.Info("found repo", repo.GoPath(), repo.Status.Path())
}
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)

View File

@ -5,9 +5,16 @@ import (
"os" "os"
"strings" "strings"
"go.wit.com/lib/gui/shell"
"go.wit.com/log" "go.wit.com/log"
) )
func addDir(d string) {
if shell.IsDir(d) {
rv.NewRepo(d)
}
}
func readControlFile() error { func readControlFile() error {
file, err := os.Open("go.work") file, err := os.Open("go.work")
if err != nil { if err != nil {
@ -29,6 +36,7 @@ func readControlFile() error {
continue continue
} }
log.Info(line) log.Info(line)
addDir(line)
} }
if err := scanner.Err(); err != nil { if err := scanner.Err(); err != nil {