sheet-historical-data-conve.../configs/configurationManager.go

45 lines
842 B
Go

package configs
import (
"fmt"
"io/ioutil"
"os"
"github.com/BurntSushi/toml"
)
type config Configurations
type Configurations struct {
OutputCurrencyFormat string
OutputFileFormat []string
InputFile []InputFile
QuarterlySummary bool
YearlySummary bool
DailyToMonthlyAggregationMethod string
}
type InputFile struct {
FileName string
SheetName string
Measurement string
}
func ReadConfigs(tomlFile string) Configurations {
bytesOfData, error := ioutil.ReadFile(tomlFile)
if error != nil {
fmt.Println("Error: ", error)
os.Exit(1)
}
appConfig := Configurations{}
if _, err := toml.Decode(string(bytesOfData), &appConfig); err != nil {
fmt.Println("Error: ", error)
os.Exit(1)
}
fmt.Println(appConfig)
return appConfig
}