Skip to content

Commit

Permalink
feat: default -> set (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
ForrestSu committed Sep 3, 2022
1 parent 7e4689c commit 38be347
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ $ GOUP_GO_HOST=golang.google.cn goup install # For Gophers in China, see https:/

* `install.sh` downloads the latest Goup release for your platform and appends Goup's bin directory (`$HOME/.go/bin`) & Go's bin directory (`$HOME/.go/current/bin`) to your PATH environment variable.
* `goup` switches to selected Go version.
* `goup default` switches to selected Go version.
* `goup set` switches to selected Go version.
* `goup install` downloads specified version of Go to`$HOME/.go/VERSION` and symlinks it to `$HOME/.go/current`.
* `goup ls` list all installed Go version located at `$HOME/.go/current`.
* `goup remove` removes the specified Go version.
Expand Down
4 changes: 2 additions & 2 deletions ftest/ftest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ func TestGoup(t *testing.T) {
}
})

t.Run("goup default 1.15.2", func(t *testing.T) {
cmd := exec.Command(goupBin, "default", "1.15.2")
t.Run("goup set 1.15.2", func(t *testing.T) {
cmd := exec.Command(goupBin, "set", "1.15.2")
execCmd(t, cmd)
})

Expand Down
2 changes: 1 addition & 1 deletion internal/commands/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func NewCommand() *cobra.Command {
rootCmd.PersistentFlags().BoolVarP(&rootCmdVerboseFlag, "verbose", "v", false, "Verbose")

rootCmd.AddCommand(installCmd())
rootCmd.AddCommand(defaultCmd())
rootCmd.AddCommand(setCmd())
rootCmd.AddCommand(removeCmd())
rootCmd.AddCommand(initCmd())
rootCmd.AddCommand(listCmd())
Expand Down
12 changes: 6 additions & 6 deletions internal/commands/default.go → internal/commands/set.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@ import (
"github.com/spf13/cobra"
)

func defaultCmd() *cobra.Command {
func setCmd() *cobra.Command {
return &cobra.Command{
Use: "default <VERSION>...",
Use: "set <VERSION>...",
Short: "Set the default Go version",
Long: `Set the default Go version to one specified. If no version is provided,
a prompt will show to select a installed Go version.`,
Example: `
goup default # A prompt will show to select a version
goup default 1.15.2
goup set # A prompt will show to select a version
goup set 1.15.2
`,
RunE: runDefault,
RunE: runSetDefault,
}
}

func runDefault(cmd *cobra.Command, args []string) error {
func runSetDefault(cmd *cobra.Command, args []string) error {
if len(args) > 0 {
return switchVer(args[0])
}
Expand Down

0 comments on commit 38be347

Please sign in to comment.