Skip to content

Commit f07bf43

Browse files
Fix install list command to show installable versions from remote (#531)
1 parent 7226986 commit f07bf43

3 files changed

Lines changed: 17 additions & 10 deletions

File tree

cmd/core/install.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@ func runInstall(cmd *cobra.Command, args []string) error {
117117

118118
// Handle --list flag
119119
if installFlags.list {
120+
// Set remote flag so runList shows available versions, not installed ones
121+
listFlags.remote = true
120122
return runList(cmd, args)
121123
}
122124

cmd/core/list.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package core
33
import (
44
"encoding/json"
55
"fmt"
6+
67
"github.com/go-nv/goenv/cmd/legacy"
78

89
cmdpkg "github.com/go-nv/goenv/cmd"
@@ -72,6 +73,7 @@ func runListInstalled(cmd *cobra.Command) error {
7273
legacy.VersionsFlags.Bare = listFlags.bare
7374
legacy.VersionsFlags.SkipAliases = listFlags.skipAliases
7475
legacy.VersionsFlags.Json = listFlags.json
76+
legacy.VersionsFlags.SuppressDeprecationWarning = true // Don't show warning when called from 'list'
7577

7678
// Reuse the versions command implementation
7779
return legacy.RunVersions(cmd, []string{})

cmd/legacy/versions.go

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,13 @@ Examples:
5151
}
5252

5353
var VersionsFlags struct {
54-
Bare bool
55-
SkipAliases bool
56-
Complete bool
57-
Json bool
58-
Used bool
59-
Depth int
54+
Bare bool
55+
SkipAliases bool
56+
Complete bool
57+
Json bool
58+
Used bool
59+
Depth int
60+
SuppressDeprecationWarning bool // Internal flag to suppress warning when called from 'goenv list'
6061
}
6162

6263
func init() {
@@ -116,10 +117,12 @@ func RunVersions(cmd *cobra.Command, args []string) error {
116117
return nil
117118
}
118119

119-
// Deprecation warning
120-
fmt.Fprintf(cmd.OutOrStderr(), "%sDeprecation warning: 'goenv versions' is a legacy command. Use 'goenv list' instead.\n", utils.Emoji("⚠️ "))
121-
fmt.Fprintf(cmd.OutOrStderr(), " Modern command: goenv list\n")
122-
fmt.Fprintf(cmd.OutOrStderr(), " See: goenv help list\n\n")
120+
// Deprecation warning (suppressed when called internally from 'goenv list')
121+
if !VersionsFlags.SuppressDeprecationWarning {
122+
fmt.Fprintf(cmd.OutOrStderr(), "%sDeprecation warning: 'goenv versions' is a legacy command. Use 'goenv list' instead.\n", utils.Emoji("⚠️ "))
123+
fmt.Fprintf(cmd.OutOrStderr(), " Modern command: goenv list\n")
124+
fmt.Fprintf(cmd.OutOrStderr(), " See: goenv help list\n\n")
125+
}
123126

124127
// Handle invalid arguments (BATS test expects usage error)
125128
if err := cmdutil.ValidateMaxArgs(args, 0, "no arguments"); err != nil {

0 commit comments

Comments
 (0)