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

Add --bin flag to specify binary path #56

Merged
merged 1 commit into from
Oct 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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")
Expand Down Expand Up @@ -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 {
Expand Down