Skip to content

Commit

Permalink
Small fix for listing with max results (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisTerBeke committed Mar 7, 2024
1 parent e8b112b commit 5c5f36f
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions cmd/list.go
Expand Up @@ -40,6 +40,7 @@ var (
Example: listExample,
Run: func(cmd *cobra.Command, args []string) {

// find the correct type of versions to list
var versions []string
if installed {
versions = list.GetInstalledVersions()
Expand All @@ -49,12 +50,19 @@ var (
versions = list.GetAvailableVersions()
}

limit := min(maxResults, len(versions))
for _, version := range versions[:limit] {
// filter out pre-release versions if needed
var finalList []string
for _, version := range versions {
if !helpers.IsPreReleaseVersion(version) || includePreReleaseVersions {
fmt.Println(helpers.ColoredVersion(version))
finalList = append(finalList, version)
}
}

// show the list taking into consideration the max results
limit := min(maxResults, len(versions))
for _, version := range finalList[:limit] {
fmt.Println(helpers.ColoredVersion(version))
}
},
}
)
Expand Down

0 comments on commit 5c5f36f

Please sign in to comment.