Skip to content

Commit

Permalink
Provide default product in help for product command line argument
Browse files Browse the repository at this point in the history
Issue #315

Co-authored-by: George L. Yermulnik <[email protected]>
  • Loading branch information
MatthewJohn and yermulnik committed May 28, 2024
1 parent 41885ef commit 700f107
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
1 change: 1 addition & 0 deletions lib/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@ const (
InstallDir = ".terraform.versions"
recentFilePrefix = "RECENT"
tfDarwinArm64StartVersion = "1.0.2"
DefaultProductId = "terraform"
)
5 changes: 2 additions & 3 deletions lib/param_parsing/parameters.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,11 @@ func GetParameters() Params {
getopt.StringVarLong(&params.LatestStable, "latest-stable", 's', "Latest implicit version based on a constraint. Ex: tfswitch --latest-stable 0.13.0 downloads 0.13.7 and 0.13 downloads 0.15.5 (latest)")
getopt.BoolVarLong(&params.ListAllFlag, "list-all", 'l', "List all versions of terraform - including beta and rc")
getopt.StringVarLong(&params.LogLevel, "log-level", 'g', "Set loglevel for tfswitch. One of (INFO, NOTICE, DEBUG, TRACE)")

getopt.StringVarLong(&params.MirrorURL, "mirror", 'm', "install from a remote API other than the default. Default (based on product):\n"+strings.Join(defaultMirrors, "\n"))
getopt.BoolVarLong(&params.ShowLatestFlag, "show-latest", 'U', "Show latest stable version")
getopt.StringVarLong(&params.ShowLatestPre, "show-latest-pre", 'P', "Show latest pre-release implicit version. Ex: tfswitch --show-latest-pre 0.13 prints 0.13.0-rc1 (latest)")
getopt.StringVarLong(&params.ShowLatestStable, "show-latest-stable", 'S', "Show latest implicit version. Ex: tfswitch --show-latest-stable 0.13 prints 0.13.7 (latest)")
getopt.StringVarLong(&params.Product, "product", 'q', fmt.Sprintf("Specifies which product to use. Ex: `tfswitch --product terraform` will install Terraform. Options: (%s)", strings.Join(productIds, ", ")))
getopt.StringVarLong(&params.Product, "product", 'q', fmt.Sprintf("Specifies which product to use. Ex: `tfswitch --product opentofu` will install Terraform. Options: (%s). Default: %s", strings.Join(productIds, ", "), lib.DefaultProductId))
getopt.BoolVarLong(&params.VersionFlag, "version", 'v', "Displays the version of tfswitch")

// Parse the command line parameters to fetch stuff like chdir
Expand Down Expand Up @@ -127,7 +126,7 @@ func initParams(params Params) Params {
params.ShowLatestPre = lib.DefaultLatest
params.ShowLatestStable = lib.DefaultLatest
params.Version = lib.DefaultLatest
params.Product = "terraform"
params.Product = lib.DefaultProductId
params.VersionFlag = false
return params
}

0 comments on commit 700f107

Please sign in to comment.