Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Rename goup show to goup ls #42

Merged
merged 1 commit into from
Sep 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Downloaded 100.0% (121149509 / 121149509 bytes)
INFO[0030] Unpacking /home/owen/.go/go1.15.2/go1.15.2.linux-amd64.tar.gz ...
INFO[0043] Success: go1.15.2 downloaded in /home/owen/.go/go1.15.2
INFO[0043] Default Go is set to 'go1.15.2'
$ goup show
$ goup ls
go1.15.2
$ go env GOROOT
/home/owen/.go/go1.15.2
Expand Down Expand Up @@ -85,7 +85,7 @@ Building packages and commands for linux/amd64.
Installed Go for linux/amd64 in /home/owen/.go/gotip
Installed commands in /home/owen/.go/gotip/bin
INFO[0297] Default Go is set to 'gotip'
$ goup show
$ goup ls
gotip
$ go env GOROOT
/home/owen/.go/gotip
Expand All @@ -102,7 +102,7 @@ $ GOUP_GO_HOST=golang.google.cn goup install # For Gophers in China, see https:/
* `goup` switches to selected Go version.
* `goup default` switches to selected Go version.
* `goup install` downloads specified version of Go to`$HOME/.go/VERSION` and symlinks it to `$HOME/.go/current`.
* `goup show` shows the activated Go version located at `$HOME/.go/current`.
* `goup ls` list all installed Go version located at `$HOME/.go/current`.
* `goup remove` removes the specified Go version.
* `goup search` lists all available Go versions from https://golang.org/dl.
* `goup upgrade` upgrades goup.
Expand Down
24 changes: 12 additions & 12 deletions ftest/ftest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,12 @@ func TestGoup(t *testing.T) {
execCmd(t, cmd)
})

t.Run("goup show 1.15.2", func(t *testing.T) {
cmd := exec.Command(goupBin, "show")
t.Run("goup ls 1.15.2", func(t *testing.T) {
cmd := exec.Command(goupBin, "list")
out := execCmd(t, cmd)

if want, got := []byte("1.15.2"), out; !bytes.Contains(got, want) {
t.Fatalf("goup show failed: want=%s got=%s", want, out)
t.Fatalf("goup list failed: want=%s got=%s", want, out)
}
})

Expand All @@ -104,12 +104,12 @@ func TestGoup(t *testing.T) {
execCmd(t, cmd)
})

t.Run("goup show 1.15.3", func(t *testing.T) {
cmd := exec.Command(goupBin, "show")
t.Run("goup ls 1.15.3", func(t *testing.T) {
cmd := exec.Command(goupBin, "list")
out := execCmd(t, cmd)

if want, got := []byte("1.15.3"), out; !bytes.Contains(got, want) {
t.Fatalf("goup show failed: want=%s got=%s", want, out)
t.Fatalf("goup list failed: want=%s got=%s", want, out)
}
})

Expand All @@ -118,12 +118,12 @@ func TestGoup(t *testing.T) {
execCmd(t, cmd)
})

t.Run("goup show 1.15.2", func(t *testing.T) {
cmd := exec.Command(goupBin, "show")
t.Run("goup ls 1.15.2", func(t *testing.T) {
cmd := exec.Command(goupBin, "list")
out := execCmd(t, cmd)

if want, got := []byte("1.15.2"), out; !bytes.Contains(got, want) {
t.Fatalf("goup show failed: want=%s got=%s", want, out)
t.Fatalf("goup list failed: want=%s got=%s", want, out)
}
})

Expand All @@ -141,12 +141,12 @@ func TestGoup(t *testing.T) {
execCmd(t, cmd)
})

t.Run("goup show does not have 1.15.2", func(t *testing.T) {
cmd := exec.Command(goupBin, "show")
t.Run("goup ls does not have 1.15.2", func(t *testing.T) {
cmd := exec.Command(goupBin, "list")
out := execCmd(t, cmd)

if want, got := []byte("1.15.2"), out; bytes.Contains(got, want) {
t.Fatalf("goup show again failed: want=%s got=%s", want, out)
t.Fatalf("goup list again failed: want=%s got=%s", want, out)
}
})

Expand Down
13 changes: 7 additions & 6 deletions internal/commands/show.go → internal/commands/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,17 @@ import (
"github.com/spf13/cobra"
)

func showCmd() *cobra.Command {
func listCmd() *cobra.Command {
return &cobra.Command{
Use: "show",
Short: "Show installed Go",
Long: "Show installed Go versions.",
RunE: runShow,
Use: "ls",
Aliases: []string{"list"},
Short: "List all installed Go",
Long: "List all installed Go versions.",
RunE: runList,
}
}

func runShow(cmd *cobra.Command, args []string) error {
func runList(cmd *cobra.Command, args []string) error {
vers, err := listGoVers()
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion internal/commands/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func NewCommand() *cobra.Command {
rootCmd.AddCommand(defaultCmd())
rootCmd.AddCommand(removeCmd())
rootCmd.AddCommand(initCmd())
rootCmd.AddCommand(showCmd())
rootCmd.AddCommand(listCmd())
rootCmd.AddCommand(searchCmd())
rootCmd.AddCommand(versionCmd())
rootCmd.AddCommand(upgradeCmd())
Expand Down
4 changes: 2 additions & 2 deletions internal/commands/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ list all available versions.`,
goup search
goup search 1.15
`,
RunE: runList,
RunE: runSearch,
}
}

func runList(cmd *cobra.Command, args []string) error {
func runSearch(cmd *cobra.Command, args []string) error {
var regexp string
if len(args) > 0 {
regexp = args[0]
Expand Down