Skip to content

Commit 1fe7359

Browse files
committed
move loading env file to config.go
1 parent 02d5c3d commit 1fe7359

File tree

2 files changed

+19
-26
lines changed

2 files changed

+19
-26
lines changed

cli/config.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ import (
55
"errors"
66
"fmt"
77
"io"
8+
"log/slog"
89
"os"
910
"path/filepath"
1011

12+
"github.com/joho/godotenv"
1113
"github.com/pelletier/go-toml/v2"
1214
"golang.org/x/term"
1315
)
@@ -23,6 +25,8 @@ var (
2325
DispatchConsoleUrl string
2426

2527
DispatchConfigPath string
28+
29+
DotEnvFilePath string
2630
)
2731

2832
func init() {
@@ -148,3 +152,18 @@ func runConfigFlow() error {
148152
}
149153
return nil
150154
}
155+
156+
func loadEnvFromFile(path string) error {
157+
if path != "" {
158+
absolutePath, err := filepath.Abs(path)
159+
if err != nil {
160+
return fmt.Errorf("failed to get absolute path for %s: %v", path, err)
161+
}
162+
if err := godotenv.Load(path); err != nil {
163+
return fmt.Errorf("failed to load env file from %s: %v", absolutePath, err)
164+
}
165+
slog.Info("loading environment variables from file", "path", absolutePath)
166+
}
167+
setVariables()
168+
return nil
169+
}

cli/env_file.go

Lines changed: 0 additions & 26 deletions
This file was deleted.

0 commit comments

Comments
 (0)