use go-mod-clean
This commit is contained in:
parent
e69a078b75
commit
5f1f19d9ca
18
main.go
18
main.go
|
@ -125,10 +125,20 @@ func clone() {
|
|||
badExit(err)
|
||||
}
|
||||
|
||||
// update go.sum and go.mod
|
||||
// todo: only do this if they don't exist?
|
||||
// todo: make these git commit metadata
|
||||
pb.RedoGoMod()
|
||||
if err := pb.ValidGoSum(); err != nil {
|
||||
// update go.sum and go.mod
|
||||
if err := pb.RunStrict([]string{"go-mod-clean"}); err != nil {
|
||||
log.Info("")
|
||||
log.Info("Do you have go-mod-clean? Otherwise:")
|
||||
log.Info(" go install go.wit.com/apps/go-mod-clean@latest")
|
||||
log.Info("")
|
||||
badExit(err)
|
||||
}
|
||||
}
|
||||
if err := pb.ValidGoSum(); err != nil {
|
||||
log.Info("could not generate valid go.sum file")
|
||||
badExit(err)
|
||||
}
|
||||
|
||||
// double check it actually downloaded
|
||||
fullgitdir := filepath.Join(forge.GetGoSrc(), argv.Repo, ".git")
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"go.wit.com/log"
|
||||
)
|
||||
|
||||
func showOptions(b bool, s []string) {
|
||||
fmt.Println("")
|
||||
for _, line := range s {
|
||||
fmt.Println(line)
|
||||
}
|
||||
fmt.Println("")
|
||||
if b {
|
||||
fmt.Println("Enter (Y/n)")
|
||||
} else {
|
||||
fmt.Println("Enter (y/N)")
|
||||
}
|
||||
}
|
||||
|
||||
// if b == true, default is to continue with 'Y'
|
||||
func simpleStdin(b bool, s []string) {
|
||||
/*
|
||||
if argv.Auto {
|
||||
return
|
||||
}
|
||||
*/
|
||||
err := errors.New("user cancelled via stdin")
|
||||
showOptions(b, s)
|
||||
scanner := bufio.NewScanner(os.Stdin)
|
||||
for scanner.Scan() {
|
||||
s := scanner.Text()
|
||||
s = strings.TrimSpace(s)
|
||||
s = strings.ToLower(s)
|
||||
switch s {
|
||||
case "y":
|
||||
log.Info("got y")
|
||||
return
|
||||
case "n":
|
||||
log.Info("got n")
|
||||
badExit(err)
|
||||
case "":
|
||||
if b {
|
||||
return
|
||||
} else {
|
||||
badExit(err)
|
||||
}
|
||||
default:
|
||||
badExit(err)
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue