Skip to content

Commit

Permalink
add some versions you can install
Browse files Browse the repository at this point in the history
  • Loading branch information
drewgonzales360 committed May 6, 2022
1 parent 53e0e58 commit 1743692
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 1 deletion.
71 changes: 71 additions & 0 deletions internal/cmd/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,89 @@ import (
"fmt"
"os"

"github.com/Masterminds/semver"
"github.com/urfave/cli/v2"
)

type versionRange struct {
minVerson semver.Version
maxVerson semver.Version
}

var goVersion map[string][]string = map[string][]string{
"1.18": {
"1.18.1",
"1.18",
},
"1.17": {
"1.17.9",
"1.17.8",
"1.17.7",
"1.17.6",
"1.17.5",
"1.17.4",
"1.17.3",
"1.17.2",
"1.17.1",
"1.17",
},
"1.16": {
"1.16.15",
"1.16.14",
"1.16.13",
"1.16.12",
"1.16.11",
"1.16.10",
"1.16.9",
"1.16.8",
"1.16.7",
"1.16.6",
"1.16.5",
"1.16.4",
"1.16.3",
"1.16.2",
"1.16.1",
"1.16",
},
"1.15": {
"1.15.15",
"1.15.14",
"1.15.13",
"1.15.12",
"1.15.11",
"1.15.10",
"1.15.9",
"1.15.8",
"1.15.7",
"1.15.6",
"1.15.5",
"1.15.4",
"1.15.3",
"1.15.2",
"1.15.1",
"1.15",
},
}

func ListCommand(c *cli.Context) error {
versions, err := os.ReadDir(InstallDirectory)
if err != nil {
return err
}

if c.Bool("available") {
fmt.Println("Installed Versions:")
}
for _, version := range versions {
fmt.Println(version.Name())
}

if c.Bool("available") {
fmt.Println("Available Versions:")
for k, v := range goVersion {
fmt.Printf("%s: %v\n", k, v)
}
}

return nil
}
8 changes: 7 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,13 @@ func main() {
Name: "list",
Usage: "List all available go versions",
Aliases: []string{"ls", "l"},
Action: cmd.ListCommand,
Flags: []cli.Flag{
&cli.BoolFlag{
Name: "available",
Aliases: []string{"a"},
},
},
Action: cmd.ListCommand,
},
},
HideHelpCommand: true,
Expand Down

0 comments on commit 1743692

Please sign in to comment.