Skip to content

Commit

Permalink
add getting env from input if argument is not setted
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Neishkasha committed Jan 15, 2020
1 parent 370afbe commit dc3a16c
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"fmt"
"github.com/joho/godotenv"
"log"
"os"
Expand All @@ -10,7 +11,8 @@ func main() {
if err := godotenv.Load(); err != nil {
log.Fatal("Error loading .env file")
}
env := os.Args[1]
env := getEnv()
fmt.Println("Connecting...")
awsFacade := AwsFacade{region: os.Getenv("AWS_DEFAULT_REGION"), env: env}
ip, err := awsFacade.IP()
if err != nil {
Expand All @@ -19,3 +21,13 @@ func main() {
ssh := SshFacade{ip, env}
ssh.Connect()
}

func getEnv() string {
if len(os.Args) > 1 {
return os.Args[1]
}
var env string
fmt.Printf("Enter the name of environment (stg/prod): ")
fmt.Scanln(&env)
return env
}

0 comments on commit dc3a16c

Please sign in to comment.