Update packages (#16)
Reviewed-on: #16 Co-authored-by: phoenix <kundeng00@pm.me> Co-committed-by: phoenix <kundeng00@pm.me>
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user