bash autocomplete kinda works, kinda doesn't for some reason
This commit is contained in:
parent
9da0b69734
commit
7265c0d6a1
|
@ -28,7 +28,7 @@ func (args) doBashAuto() {
|
||||||
default:
|
default:
|
||||||
if argv.BashAuto[0] == ARGNAME {
|
if argv.BashAuto[0] == ARGNAME {
|
||||||
// list the subcommands here
|
// list the subcommands here
|
||||||
fmt.Println("--bash strict --force")
|
fmt.Println("--smart strict")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
|
@ -45,12 +45,9 @@ func (args) doBashHelp() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if argv.BashAuto[0] == ARGNAME {
|
if argv.BashAuto[0] == ARGNAME {
|
||||||
pp.WriteHelp(os.Stderr)
|
// pp.WriteHelp(os.Stderr)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
fmt.Fprintln(os.Stderr, "")
|
|
||||||
fmt.Fprintln(os.Stderr, "hello world")
|
|
||||||
fmt.Fprintln(os.Stderr, "")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// complete -F forge --bash forge
|
// complete -F forge --bash forge
|
||||||
|
|
40
doSmart.go
40
doSmart.go
|
@ -8,9 +8,6 @@ import (
|
||||||
// this will make go.mod and go.sum files, but you have to
|
// this will make go.mod and go.sum files, but you have to
|
||||||
// have the files in .gitignore for now
|
// have the files in .gitignore for now
|
||||||
func doSmart(repo *gitpb.Repo) error {
|
func doSmart(repo *gitpb.Repo) error {
|
||||||
// erase the go.mod and go.sum files
|
|
||||||
eraseGoMod(repo)
|
|
||||||
|
|
||||||
// if the repo has go.mod in the repo...
|
// if the repo has go.mod in the repo...
|
||||||
if err := repo.RepoIgnoresGoMod(); err != nil {
|
if err := repo.RepoIgnoresGoMod(); err != nil {
|
||||||
if repo.ParseGoSum() {
|
if repo.ParseGoSum() {
|
||||||
|
@ -19,51 +16,40 @@ func doSmart(repo *gitpb.Repo) error {
|
||||||
log.Info("go-mod-clean can not run on this repo", repo.GetGoPath())
|
log.Info("go-mod-clean can not run on this repo", repo.GetGoPath())
|
||||||
log.Info("go.mod and go.sum must be git metadata to continue")
|
log.Info("go.mod and go.sum must be git metadata to continue")
|
||||||
// return nil
|
// return nil
|
||||||
}
|
if repo.Exists("go.sum") {
|
||||||
if repo.Exists("go.mod") {
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
// erase the go.mod and go.sum files
|
||||||
|
eraseGoMod(repo)
|
||||||
|
|
||||||
// try to restore from the git metadata
|
// try to restore from the git metadata
|
||||||
cname := repo.GetCurrentBranchName()
|
cname := repo.GetCurrentBranchName()
|
||||||
if err := repo.AutogenRestore(cname); err == nil {
|
if err := repo.AutogenRestore(cname); err == nil {
|
||||||
log.Info(repo.GetGoPath(), "files were restored ok from git metadata (notes)")
|
log.Info(repo.GetGoPath(), "files were restored ok from git metadata (notes)")
|
||||||
}
|
|
||||||
if repo.Exists("go.mod") {
|
if repo.Exists("go.mod") {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
// autogen restore didn't find go.mod
|
||||||
// attempt to restore from ~/go/pkg/mod/
|
|
||||||
if err := restoreFromGoPkg(repo); err == nil {
|
|
||||||
log.Info(repo.GetGoPath(), "files were restored ok ~/go/mod/")
|
|
||||||
}
|
|
||||||
if repo.Exists("go.mod") {
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// actually will re-create go.sum and go.mod now
|
// actually will re-create go.sum and go.mod now
|
||||||
if err := redoGoMod(repo); err != nil {
|
if err := redoGoMod(repo); err != nil {
|
||||||
log.Info(repo.GetGoPath(), "the files were restored with redoGoMod()")
|
return err
|
||||||
}
|
}
|
||||||
|
log.Info(repo.GetGoPath(), "the files were restored with redoGoMod()")
|
||||||
if repo.Exists("go.mod") {
|
if repo.Exists("go.mod") {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// the first time, it'll attempt to fix some stuff
|
// the first time, it'll attempt to fix some stuff
|
||||||
cleanGoDepsCheckOk(repo)
|
if err := cleanGoDepsCheckOk(repo); err != nil {
|
||||||
// try to trim junk
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// trim junk that might have been added by cleanGoDepsCheckOk()
|
||||||
if err := trimGoSum(repo); err != nil {
|
if err := trimGoSum(repo); err != nil {
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
if repo.Exists("go.mod") {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
repo.ParseGoSum()
|
|
||||||
|
|
||||||
if repo.Exists("go.mod") {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
// last chance. just run go mod init
|
|
||||||
repo.RunVerbose([]string{"go", "mod", "init"})
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue