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
./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

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
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)
}
/*
if args.Gui == "" {
myGui = gui.New()
myGui.Default()
}
*/
filepath := filepath.Join("/home/jcarr/go/src", args.Repo)
os.Chdir(filepath)
var myargs args
// tmp := arg.MustParse(&myargs)
arg.MustParse(&myargs)
shell.TestTerminalColor()
if myargs.Work {
shell.Mkdir("work")
} else {
// filepath := filepath.Join("/home/jcarr/go/src")
// os.Chdir(filepath)
}
// if myargs.Repo == "" {
// // tmp.WriteHelp(os.Stdout)
// // fmt.Println("hello world")
// tmp := myargs.Description()
// fmt.Println(tmp)
// os.Exit(0)
// }
b := gui.RawBox()
rv = repolist.AutotypistView(b)
// 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)

View File

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