add ability to list installed versions

This commit is contained in:
Aaron Bieber 2021-08-15 18:23:49 +00:00
parent a3b6eb95a0
commit 553480b13e
1 changed files with 13 additions and 2 deletions

15
main.go
View File

@ -15,9 +15,9 @@ package main
import (
"bytes"
_ "embed"
"errors"
"fmt"
_ "embed"
"io"
"log"
"net/http"
@ -59,7 +59,7 @@ func main() {
_ = protect.UnveilBlock()
if len(os.Args) == 1 {
log.Fatalf("gover: usage: gover [download|version]")
log.Fatalf("gover: usage: gover [download|version|list]")
os.Exit(1)
}
@ -76,6 +76,17 @@ func main() {
log.Printf("Success. You may now run 'gover %s'!", version)
os.Exit(0)
}
if os.Args[1] == "list" {
entries, err := os.ReadDir(root)
if err != nil {
log.Fatalln(err)
}
for _, entry := range entries {
fmt.Println(entry.Name())
}
os.Exit(0)
}
version = os.Args[1]
gobin := filepath.Join(root, version, "go", "bin", "go"+exe())
gorootPath := filepath.Join(root, version, "go")