add --build and --install

This commit is contained in:
Jeff Carr 2024-12-01 22:21:34 -06:00
parent 106f1403c6
commit 5155f8038e
2 changed files with 32 additions and 13 deletions

View File

@ -52,6 +52,10 @@ git-clone:
test-build: build test-build: build
./go-clone --build go.wit.com/apps/guireleaser ./go-clone --build go.wit.com/apps/guireleaser
test-install: build
./go-clone --install go.wit.com/apps/guireleaser
debian: debian:
go-deb --no-gui --repo go.wit.com/apps/go-clone go-deb --no-gui --repo go.wit.com/apps/go-clone

39
main.go
View File

@ -82,17 +82,26 @@ func main() {
clone() clone()
autoWork() autoWork()
build() if argv.Install {
if argv.Repo == "" { if err := forge.Install(argvRepo, nil); err == nil {
pp.WriteHelp(os.Stdout) okExit("install worked")
os.Exit(0) } else {
badExit(err)
} }
okExit(argv.Repo) }
if argv.Build {
if err := forge.Build(argvRepo, nil); err == nil {
okExit("build worked")
} else {
badExit(err)
}
}
okExit("skipping build of " + argv.Repo)
} }
func okExit(thing string) { func okExit(thing string) {
log.Info("Total repositories:", forge.Repos.Len()) log.Info(thing, "ok")
log.Info("Finished go-clone", thing, "ok") log.Info("Finished clone on", argvRepo.GetGoPath(), "ok")
os.Exit(0) os.Exit(0)
} }
@ -199,13 +208,19 @@ func redoGoModAll() {
} }
} }
func build() { func build() error {
if argv.Build { if argv.Install {
log.Info("need to try to build here") if err := forge.Install(argvRepo, nil); err == nil {
forge.Build(argvRepo, nil) okExit("install worked")
} else { } else {
log.Info("skipping build") badExit(err)
} }
}
if argv.Build {
return forge.Build(argvRepo, nil)
}
log.Info("skipping build")
return nil
} }
func autoWork() { func autoWork() {