Skip to content

Commit 06f663b

Browse files
committed
Make --env-file option available in any command
1 parent 62c931c commit 06f663b

File tree

3 files changed

+3
-6
lines changed

3 files changed

+3
-6
lines changed

cli/login.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@ account or login to an existing account.
2222
2323
After authenticating with Dispatch, the API key will be persisted locally.`,
2424
GroupID: "management",
25-
PreRunE: func(cmd *cobra.Command, args []string) error {
26-
return loadEnvFromFile(DotEnvFilePath)
27-
},
2825
RunE: func(cmd *cobra.Command, args []string) error {
2926
token, err := generateToken()
3027
if err != nil {

cli/main.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ Documentation: https://docs.dispatch.run
1919
Discord: https://dispatch.run/discord
2020
2121
`,
22+
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
23+
return loadEnvFromFile(DotEnvFilePath)
24+
},
2225
RunE: func(cmd *cobra.Command, args []string) error {
2326
return cmd.Help()
2427
},

cli/run.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,6 @@ previous run.`, defaultEndpoint),
8484
SilenceUsage: true,
8585
GroupID: "dispatch",
8686
PreRunE: func(cmd *cobra.Command, args []string) error {
87-
if err := loadEnvFromFile(DotEnvFilePath); err != nil {
88-
return err
89-
}
9087
return runConfigFlow()
9188
},
9289
RunE: func(c *cobra.Command, args []string) error {

0 commit comments

Comments
 (0)