Skip to content

Commit

Permalink
Merge pull request warrensbox#56 from lumasepa/Add-bin-path-flag
Browse files Browse the repository at this point in the history
Add --bin flag to specify binary path

Merge to master. Will be tested before released.
warrensbox authored Oct 14, 2019
2 parents 609fc99 + 5ae348a commit e0d50b8
Showing 2 changed files with 8 additions and 3 deletions.
6 changes: 5 additions & 1 deletion lib/install.go
Original file line number Diff line number Diff line change
@@ -52,7 +52,11 @@ func init() {
}

//Install : Install the provided version in the argument
func Install(url string, appversion string, assests []modal.Repo) string {
func Install(url string, appversion string, assests []modal.Repo, userBinPath * string) string {
/* If user provided bin path use user one instead of default */
if userBinPath != nil {
installedBinPath = *userBinPath
}

/* check if selected version already downloaded */
fileExist := CheckFileExist(installLocation + installVersion + appversion)
5 changes: 3 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
@@ -43,6 +43,7 @@ func main() {
client.ClientID = CLIENT_ID
client.ClientSecret = CLIENT_SECRET

userBinPath := getopt.StringLong("bin", 'b', "Custom binary path. For example: /Users/username/bin/terragrunt")
versionFlag := getopt.BoolLong("version", 'v', "displays the version of tgswitch")
helpFlag := getopt.BoolLong("help", 'h', "displays help message")
_ = versionFlag
@@ -67,7 +68,7 @@ func main() {
exist := lib.VersionExist(requestedVersion, tflist)

if exist {
installLocation := lib.Install(terragruntURL, requestedVersion, assets)
installLocation := lib.Install(terragruntURL, requestedVersion, assets, userBinPath)
lib.AddRecent(requestedVersion, installLocation) //add to recent file for faster lookup
} else {
fmt.Println("Not a valid terragrunt version")
@@ -99,7 +100,7 @@ func main() {
os.Exit(1)
}

installLocation := lib.Install(terragruntURL, tgversion, assets)
installLocation := lib.Install(terragruntURL, tgversion, assets, userBinPath)
lib.AddRecent(tgversion, installLocation) //add to recent file for faster lookup
os.Exit(0)
} else {

0 comments on commit e0d50b8

Please sign in to comment.