Reviewed-on: #16 Co-authored-by: phoenix <kundeng00@pm.me> Co-committed-by: phoenix <kundeng00@pm.me>
47 lines
739 B
Go
47 lines
739 B
Go
package config
|
|
|
|
import (
|
|
"encoding/json"
|
|
"flag"
|
|
"log"
|
|
"os"
|
|
|
|
"git.kundeng.us/phoenix/textsender-models/tx0/config"
|
|
)
|
|
|
|
const (
|
|
App_Name = "sender"
|
|
)
|
|
|
|
func IsVersionFlagPresent() bool {
|
|
versionFlag := flag.Bool("version", false, "Print version information")
|
|
flag.Parse()
|
|
|
|
if *versionFlag {
|
|
return true
|
|
} else {
|
|
return false
|
|
}
|
|
}
|
|
|
|
func ParseConfig(filepath string) (config config.TwilioConfig, success bool) {
|
|
content, err := os.ReadFile(filepath)
|
|
|
|
log.Println("Reading config file...")
|
|
log.Println(filepath)
|
|
|
|
if err != nil {
|
|
log.Println("An error reading the file")
|
|
return
|
|
}
|
|
|
|
err = json.Unmarshal(content, &config)
|
|
|
|
if err != nil {
|
|
log.Println("An error occurred")
|
|
return config, false
|
|
}
|
|
|
|
return config, true
|
|
}
|