mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
add dotenv string flag for changing dotenv filename
This commit is contained in:
parent
0a29ee99b8
commit
eebb568b0c
2
go.mod
2
go.mod
|
@ -21,7 +21,7 @@ require (
|
|||
github.com/gorilla/websocket v1.4.2
|
||||
github.com/jehiah/go-strftime v0.0.0-20171201141054-1d33003b3869 // indirect
|
||||
github.com/jmoiron/sqlx v1.2.0
|
||||
github.com/joho/godotenv v1.3.0 // indirect
|
||||
github.com/joho/godotenv v1.3.0
|
||||
github.com/json-iterator/go v1.1.10 // indirect
|
||||
github.com/leekchan/accounting v0.0.0-20191218023648-17a4ce5f94d4
|
||||
github.com/leodido/go-urn v1.2.1 // indirect
|
||||
|
|
|
@ -38,7 +38,9 @@ func init() {
|
|||
RunCmd.Flags().String("totp-account-name", "", "")
|
||||
RunCmd.Flags().Bool("enable-web-server", false, "enable web server")
|
||||
RunCmd.Flags().Bool("setup", false, "use setup mode")
|
||||
|
||||
RunCmd.Flags().Bool("no-dotenv", false, "disable built-in dotenv")
|
||||
RunCmd.Flags().String("dotenv", ".env.local", "the dotenv file you want to load")
|
||||
|
||||
RunCmd.Flags().String("since", "", "pnl since time")
|
||||
RootCmd.AddCommand(RunCmd)
|
||||
|
@ -250,8 +252,13 @@ func run(cmd *cobra.Command, args []string) error {
|
|||
}
|
||||
|
||||
if !disableDotEnv {
|
||||
if err := godotenv.Load(".env.local", ".env") ; err != nil {
|
||||
return errors.Wrap(err, "error loading .env file")
|
||||
dotenvFile, err := cmd.Flags().GetString("dotenv")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := godotenv.Load(dotenvFile); err != nil {
|
||||
return errors.Wrap(err, "error loading dotenv file")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user