summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-11-07 07:03:51 -0600
committerJeff Carr <[email protected]>2024-11-07 07:03:51 -0600
commit5abf602bf7491e415921cb68e058f7def18db2ad (patch)
tree39b6878286a477c3ab06cfb99c01e4756311dd68
parentd576aa8a25b9ee3606396c3e61cfc3c5f117b627 (diff)
rename to 'argv'; use standard -ldflagsv0.5.3
-rw-r--r--Makefile5
-rw-r--r--README.md4
-rw-r--r--argv.go4
-rw-r--r--main.go36
4 files changed, 30 insertions, 19 deletions
diff --git a/Makefile b/Makefile
index 89e7cc6..a449dc0 100644
--- a/Makefile
+++ b/Makefile
@@ -23,7 +23,8 @@ no-gui: build
./go-clone --no-gui
build:
- GO111MODULE=off go build -v -ldflags "-X main.Version=${VERSION} -X gui.GUIVERSION=${VERSION}"
+ GO111MODULE=off go build -v \
+ -ldflags "-X main.VERSION=${VERSION} -X gui.GUIVERSION=${VERSION}"
build-go-1.21:
@#GO111MODULE=off /usr/lib/go-1.21/bin/go build -v -ldflags "-X main.VERSION=${VERSION}"
@@ -45,7 +46,7 @@ reset:
# clear your terminal
reset
-gocui: build
+gui-gocui: build
reset
./go-clone --gui gocui >/tmp/witgui.log.stderr 2>&1
diff --git a/README.md b/README.md
index 9409245..a32d26d 100644
--- a/README.md
+++ b/README.md
@@ -16,6 +16,10 @@ Or to recursively clone all the build dependancies:
go-clone --recursive go.wit.com/apps/go-clone
+## debian packages
+
+ Debian packages are at mirrors.wit.com
+
## TODO:
* use protobuf
diff --git a/argv.go b/argv.go
index ec2a408..2d04a27 100644
--- a/argv.go
+++ b/argv.go
@@ -6,6 +6,8 @@ package main
this enables command line options from other packages like 'gui' and 'log'
*/
+var argv args
+
type args struct {
Repo string `arg:"positional" help:"go import path"`
NoWork bool `arg:"--no-work" default:"true" help:"do not make or modify the go.work file"`
@@ -28,5 +30,5 @@ This will recursively clone the app and all the build requirements:
}
func (args) Version() string {
- return "go-clone " + Version
+ return "go-clone " + VERSION
}
diff --git a/main.go b/main.go
index 6972703..36ed05f 100644
--- a/main.go
+++ b/main.go
@@ -14,25 +14,21 @@ import (
"go.wit.com/log"
)
-var Version string
+// sent from -ldflags
+var VERSION string
var rv *repolist.RepoList
-var myargs args
func main() {
- pp := arg.MustParse(&myargs)
+ pp := arg.MustParse(&argv)
- if myargs.Repo == "" {
+ if argv.Repo == "" {
pp.WriteHelp(os.Stdout)
os.Exit(0)
}
- if myargs.Repo == "version" {
- log.Info(Version)
- os.Exit(0)
- }
-
- if myargs.Repo == "version" || myargs.Repo == "help" || myargs.Repo == "?" {
+ // for very new users or users unfamilar with the command line, this may help them
+ if argv.Repo == "version" || argv.Repo == "help" || argv.Repo == "?" {
pp.WriteHelp(os.Stdout)
os.Exit(0)
}
@@ -52,13 +48,21 @@ func main() {
rv = repolist.AutotypistView(b)
os.Setenv("REPO_AUTO_CLONE", "true")
- newr, err := rv.NewRepo(myargs.Repo)
+ newr, err := rv.NewRepo(argv.Repo)
if err != nil {
log.Info("could not download:", err)
os.Exit(-1)
}
newr.Status.MakeRedomod()
+ fullgitdir := filepath.Join(wdir, argv.Repo, ".git")
+ if shell.IsDir(fullgitdir) {
+ log.Info("repo already cloned", filepath.Join(wdir, argv.Repo))
+ os.Exit(0)
+ }
+
+ log.Info("scanning for repo in:", filepath.Join(wdir, argv.Repo))
+
// rv.NewRepo("go.wit.com/apps/helloworld")
for _, path := range repostatus.ScanGitDirectories(wdir) {
gopath := strings.TrimPrefix(path, wdir)
@@ -68,7 +72,7 @@ func main() {
}
godep := newr.Status.GetGoDeps()
- if myargs.Recursive {
+ if argv.Recursive {
for gopath, version := range godep {
repo, err := rv.NewRepo(gopath)
if err != nil {
@@ -88,8 +92,8 @@ func main() {
}
log.Info("Total repositories:", count)
- log.Info("Finished go-clone for", myargs.Repo)
- if !myargs.NoWork {
+ log.Info("Finished go-clone for", argv.Repo)
+ if !argv.NoWork {
log.Info("Creating", wdir+"/go.work")
rv.MakeGoWork()
shell.RunPath(wdir, []string{"go", "work", "use"})
@@ -105,7 +109,7 @@ func main() {
// look for or make a go.work file
// otherwise use ~/go/src
func findWorkFile() (string, error) {
- if myargs.GoSrc {
+ if argv.GoSrc {
// user put --go-src on the command line so use ~/go/src
return useGoSrc()
}
@@ -120,7 +124,7 @@ func findWorkFile() (string, error) {
}
// if the user added '--work' on the cmdline, make a work directory and init the go.work file
- if ! myargs.NoWork {
+ if !argv.NoWork {
pwd, err = os.Getwd()
newpwd := filepath.Join(pwd, "work")
shell.Mkdir(newpwd)