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

Don't allow negative value to be passed for --max-results flag #33

Merged
merged 2 commits into from Mar 9, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions cmd/list.go
Expand Up @@ -32,7 +32,7 @@ const (
var (
installed bool
aliases bool
maxResults int
maxResults uint
includePreReleaseVersions bool
listCmd = &cobra.Command{
Use: "list",
Expand All @@ -59,7 +59,7 @@ var (
}

// show the list taking into consideration the max results
limit := min(maxResults, len(finalList))
limit := min(int(maxResults), len(finalList))
for _, version := range finalList[:limit] {
fmt.Println(helpers.ColoredVersion(version))
}
Expand All @@ -71,6 +71,6 @@ func init() {
rootCmd.AddCommand(listCmd)
listCmd.Flags().BoolVar(&installed, "installed", false, "list the installed Terraform versions")
listCmd.Flags().BoolVar(&aliases, "aliases", false, "list the aliased Terraform versions")
listCmd.Flags().IntVar(&maxResults, "max-results", 500, "maximum number of versions to list")
listCmd.Flags().UintVar(&maxResults, "max-results", 500, "maximum number of versions to list")
listCmd.Flags().BoolVar(&includePreReleaseVersions, "pre-release", false, "include pre-release versions")
}