Skip to content

Commit 884270f

Browse files
committed
make config file a flag
1 parent 374b0af commit 884270f

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

internal/app/main.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,13 @@ type Config struct {
3232
}
3333

3434
func Main() {
35+
configFlag := flag.String("config", "config.yaml", "Config file")
36+
startFlag := flag.String("start", "", "Start date of period to extract from electric co.")
37+
endFlag := flag.String("end", "", "End date of period to extract from electric co.")
38+
flag.Parse()
3539

3640
// read config
37-
file, err := os.ReadFile("config.yaml")
41+
file, err := os.ReadFile(*configFlag)
3842
if err != nil {
3943
log.Fatal(err)
4044
}
@@ -47,10 +51,6 @@ func Main() {
4751
log.Fatal("ExtractDays must be between 2 and 45 per smarthub")
4852
}
4953

50-
// parse time flags
51-
startFlag := flag.String("start", "", "Start date of period to extract from electric co.")
52-
endFlag := flag.String("end", "", "End date of period to extract from electric co.")
53-
flag.Parse()
5454
var startDate, endDate time.Time
5555
if *startFlag != "" {
5656
startDate, err = time.ParseInLocation("2006-01-02", *startFlag, time.Local)

0 commit comments

Comments
 (0)