Skip to content

Commit

Permalink
feat: add parameter for dotenv file
Browse files Browse the repository at this point in the history
  • Loading branch information
eynopv committed May 24, 2024
1 parent 7cc6457 commit 2c9b96b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
16 changes: 9 additions & 7 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ var (
Use: "lac",
Version: "0.2.5",
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
internal.LoadDotEnv()
internal.LoadDotEnv(EnvironmentFilePath)

Variables = map[string]string{}

Expand Down Expand Up @@ -45,12 +45,13 @@ var (
},
}

VariablesInput []string
HeadersInput []string
Verbose bool
Variables map[string]string
Headers map[string]string
Timeout int
VariablesInput []string
HeadersInput []string
Verbose bool
Variables map[string]string
Headers map[string]string
Timeout int
EnvironmentFilePath string
)

func Execute() error {
Expand All @@ -62,4 +63,5 @@ func init() {
rootCmd.PersistentFlags().StringSliceVar(&VariablesInput, "vars", []string{}, "variables")
rootCmd.PersistentFlags().StringSliceVar(&HeadersInput, "headers", []string{}, "headers")
rootCmd.PersistentFlags().IntVarP(&Timeout, "timeout", "t", 15, "request timeout")
rootCmd.PersistentFlags().StringVar(&EnvironmentFilePath, "env", ".env", "environment file")
}
4 changes: 2 additions & 2 deletions internal/dotenv.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ import (
"github.com/joho/godotenv"
)

func LoadDotEnv() {
godotenv.Load(".env")
func LoadDotEnv(filePath string) {
godotenv.Load(filePath)
}

0 comments on commit 2c9b96b

Please sign in to comment.