Skip to content

Commit b460ffc

Browse files
committed
Fix docs and help strings
1 parent 68a9e50 commit b460ffc

File tree

7 files changed

+29
-15
lines changed

7 files changed

+29
-15
lines changed

lib/defaults.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const (
2828
DefaultMirror = "https://releases.hashicorp.com/terraform"
2929
DefaultLatest = ""
3030
installFile = "terraform"
31-
installDir = ".terraform.versions"
31+
InstallDir = ".terraform.versions"
3232
recentFile = "RECENT"
3333
tfDarwinArm64StartVersion = "1.0.2"
3434
VersionPrefix = "terraform_"

lib/install.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func initialize(binPath string) {
4141
// will create the installDir if it does not exist
4242
func getInstallLocation(installPath string) string {
4343
/* set installation location */
44-
installLocation = filepath.Join(installPath, installDir)
44+
installLocation = filepath.Join(installPath, InstallDir)
4545

4646
/* Create local installation directory if it does not exist */
4747
createDirIfNotExist(installLocation)

lib/param_parsing/parameters.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func GetParameters() Params {
3535
getopt.StringVarLong(&params.CustomBinaryPath, "bin", 'b', "Custom binary path. Ex: tfswitch -b "+lib.ConvertExecutableExt("/Users/username/bin/terraform"))
3636
getopt.StringVarLong(&params.DefaultVersion, "default", 'd', "Default to this version in case no other versions could be detected. Ex: tfswitch --default 1.2.4")
3737
getopt.BoolVarLong(&params.HelpFlag, "help", 'h', "Displays help message")
38-
getopt.StringVarLong(&params.InstallPath, "install", 'i', "Custom install path. Ex: tfswitch -b "+lib.ConvertExecutableExt("/Users/username"))
38+
getopt.StringVarLong(&params.InstallPath, "install", 'i', "Custom install path. Ex: tfswitch -i /Users/username. The binaries will be in the sub installDir directory e.g. /Users/username/"+lib.InstallDir)
3939
getopt.BoolVarLong(&params.LatestFlag, "latest", 'u', "Get latest stable version")
4040
getopt.StringVarLong(&params.LatestPre, "latest-pre", 'p', "Latest pre-release implicit version. Ex: tfswitch --latest-pre 0.13 downloads 0.13.0-rc1 (latest)")
4141
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)")

www/docs/usage/ci-cd.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
## Set a default TF version for CI/CD pipeline
2+
23
1. When using a CI/CD pipeline, you may want a default or fallback version to avoid the pipeline from hanging.
34
2. Ex: `tfswitch -d 1.2.3` or `tfswitch --default 1.2.3` installs version `1.2.3` when no other versions could be detected.
45
[Also, see CICD example](../continuous-integration)
@@ -34,12 +35,14 @@ load-tfswitch() {
3435
add-zsh-hook chpwd load-tfswitch
3536
load-tfswitch
3637
```
38+
3739
> NOTE: if you see an error like this: `command not found: add-zsh-hook`, then you might be on an older version of zsh (see below), or you simply need to load `add-zsh-hook` by adding this to your `.zshrc`:
3840
> ```
3941
> autoload -U add-zsh-hook
4042
> ```
4143
4244
### Older version of zsh
45+
4346
```sh
4447
cd(){
4548
builtin cd "$@";
@@ -49,6 +52,7 @@ cd(){
4952
fi
5053
}
5154
```
55+
5256
## Automatically switch with fish shell
5357

5458
Add the following to the end of your `~/.config/fish/config.fish` file:

www/docs/usage/commandline.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ The most recently selected versions are presented at the top of the dropdown.
2323

2424
## Use environment variables
2525

26-
You can also set the `TF_VERSION` environment variable to your desired terraform version.
27-
For example:
26+
You can also set the `TF_VERSION` environment variable to your desired terraform version. For example:
2827

2928
```bash
3029
export TF_VERSION=0.14.4
@@ -77,7 +76,7 @@ tfswitch --mirror https://example.jfrog.io/artifactory/hashicorp`
7776

7877
## Install to non-default location
7978

80-
By default `tfswitch` will download the Terraform binary to the user home directory under this path: `/Users/warrenveerasingam/.terraform.versions`
79+
By default `tfswitch` will download the Terraform binary to the user home directory under this path: `$HOME/.terraform.versions`
8180

8281
If you want to install the binaries outside of the home directory then you can provide the `-i` or `--install` to install Terraform binaries to a non-standard path. Useful if you want to install versions of Terraform that can be shared with multiple users.
8382

www/docs/usage/config-files.md

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
## Get the version from a subdirectory
2-
While using the file configuration it might be necessary to change the working directory. You can do that with the `--chdir` or `-c` parameter.
2+
3+
While using the file configuration it might be necessary to change the working directory. You can do that with the `--chdir` or `-c` parameter.
4+
35
```bash
46
tfswitch --chdir terraform_dir
57
tfswitch -c terraform_dir
68
```
79

810
## Use version.tf file
11+
912
If a .tf file with the terraform constraints is included in the current directory, it should automatically download or switch to that terraform version.
1013
For example, the following should automatically switch terraform to the lastest version:
14+
1115
```
1216
terraform {
1317
required_version = ">= 0.12.9"
@@ -22,6 +26,7 @@ terraform {
2226
![versiontf](../static/versiontf.gif "Use version.tf")
2327

2428
## Use .tfswitchrc file
29+
2530
![tfswitchrc](../static/tfswitch-v6.gif)
2631

2732
1. Create a `.tfswitchrc` file containing the desired version
@@ -31,23 +36,27 @@ terraform {
3136
*Instead of a `.tfswitchrc` file, a `.terraform-version` file may be used for compatibility with [`tfenv`](https://github.com/tfutils/tfenv#terraform-version-file) and other tools which use it*
3237

3338
## Use .tfswitch.toml file (For non-admin - users with limited privilege on their computers)
39+
3440
This is similiar to using a .tfswitchrc file, but you can specify a custom binary path for your terraform installation
3541

3642
![toml1](../static/tfswitch-v7.gif)
3743
![toml2](../static/tfswitch-v8.gif)
3844

39-
1. Create a custom binary path. Ex: `mkdir /Users/warrenveerasingam/bin` (replace warrenveerasingam with your username)
40-
2. Add the path to your PATH. Ex: `export PATH=$PATH:/Users/warrenveerasingam/bin` (add this to your bash profile or zsh profile)
41-
3. Pass -b or --bin parameter with your custom path to install terraform. Ex: `tfswitch -b /Users/warrenveerasingam/bin/terraform 0.10.8 `
45+
1. Create a custom binary path. Ex: `mkdir $HOME/bin`
46+
2. Add the path to your PATH. Ex: `export PATH=$PATH:$HOME/bin` (add this to your bash profile or zsh profile)
47+
3. Pass -b or --bin parameter with your custom path to install terraform. Ex: `tfswitch -b $HOME/bin/terraform 0.10.8 `
4248
4. Optionally, you can create a `.tfswitch.toml` file in your terraform directory(current directory) OR in your home directory(~/.tfswitch.toml). The toml file in the current directory has a higher precedence than toml file in the home directory
4349
5. Your `.tfswitch.toml` file should look like this:
50+
4451
```ruby
45-
bin = "/Users/warrenveerasingam/bin/terraform"
52+
bin = "$HOME/bin/terraform"
4653
version = "0.11.3"
4754
```
48-
4. Run `tfswitch` and it should automatically install the required terraform version in the specified binary path
4955

50-
**NOTE**
56+
6. Run `tfswitch` and it should automatically install the required terraform version in the specified binary path
57+
58+
**NOTE**
59+
5160
1. For linux users that do not have write permission to `/usr/local/bin/`, `tfswitch` will attempt to install terraform at `$HOME/bin`. Run `export PATH=$PATH:$HOME/bin` to append bin to PATH
5261
2. For windows host, `tfswitch` need to be run under `Administrator` mode, and `$HOME/.tfswitch.toml` with `bin` must be defined (with a valid path) as minimum, below is an example for `$HOME/.tfswitch.toml` on windows
5362

@@ -56,8 +65,10 @@ bin = "C:\\Users\\<%USRNAME%>\\bin\\terraform.exe"
5665
```
5766

5867
## Use terragrunt.hcl file
68+
5969
If a terragrunt.hcl file with the terraform constraint is included in the current directory, it should automatically download or switch to that terraform version.
60-
For example, the following should automatically switch terraform to the lastest version 0.13:
70+
For example, the following should automatically switch terraform to the lastest version 0.13:
71+
6172
```ruby
6273
terragrunt_version_constraint = ">= 0.26, < 0.27"
6374
terraform_version_constraint = ">= 0.13, < 0.14"

www/docs/usage/general.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@
77
| 3 | .terraform-version |
88
| 4 | Environment variable |
99

10-
With 1 being the highest precedence and 4 the lowest
10+
With 1 being the highest precedence and 4 the lowest
1111
*(If you disagree with this order of precedence, please open an issue)*

0 commit comments

Comments
 (0)