Skip to content

Commit

Permalink
Merge branch 'feature/chdir-flag' of git://github.com/datadrivers/ter…
Browse files Browse the repository at this point in the history
…raform-switcher into datadrivers-feature/chdir-flag
  • Loading branch information
warrensbox committed Nov 23, 2021
2 parents 6924416 + 2708a3b commit 39f7d0f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,14 @@ terraform_version_constraint = ">= 0.13, < 0.14"
...
```

### Use custom mirror
To install from a remote mirror other than the default(https://releases.hashicorp.com/terraform). Use the `-m` or `--mirror` parameter.
### Gather the version from a subdirectory
```bash
tfswitch --chdir terraform
tfswitch -c terraform
```

### Use custom mirror
To install from a remote mirror other than the default(https://releases.hashicorp.com/terraform). Use the `-m` or `--mirror` parameter.
Ex: `tfswitch --mirror https://example.jfrog.io/artifactory/hashicorp`

## Automation
Expand Down
5 changes: 5 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ var version = "0.12.0\n"

func main() {
custBinPath := getopt.StringLong("bin", 'b', lib.ConvertExecutableExt(defaultBin), "Custom binary path. Ex: "+lib.ConvertExecutableExt("/Users/username/bin/terraform"))
chDirPath := getopt.StringLong("chdir", 'c', "Switch to a different working directory before executing the given command.")
listAllFlag := getopt.BoolLong("list-all", 'l', "List all versions of terraform - including beta and rc")
latestPre := getopt.StringLong("latest-pre", 'p', defaultLatest, "Latest pre-release implicit version. Ex: tfswitch --latest-pre 0.13 downloads 0.13.0-rc1 (latest)")
showLatestPre := getopt.StringLong("show-latest-pre", 'P', defaultLatest, "Show latest pre-release implicit version. Ex: tfswitch --show-latest-pre 0.13 prints 0.13.0-rc1 (latest)")
Expand All @@ -78,6 +79,10 @@ func main() {
os.Exit(1)
}

if *chDirPath != "" {
dir = dir + "/" + *chDirPath
}

homedir, errHome := homedir.Dir()
if errHome != nil {
log.Printf("Failed to get home directory %v\n", errHome)
Expand Down

0 comments on commit 39f7d0f

Please sign in to comment.