Files
sender/config/config.go
T
phoenixandphoenix 73a23c4503 tsk-6: Added version package (#10)
Closes #6

Reviewed-on: #10
Co-authored-by: phoenix <kundeng00@pm.me>
Co-committed-by: phoenix <kundeng00@pm.me>
2025-11-09 03:23:29 +00:00

48 lines
731 B
Go

package config
import (
"encoding/json"
"flag"
"fmt"
"os"
"git.kundeng.us/phoenix/sender/models"
)
const (
App_Name = "sender"
)
func IsVersionFlagPresent() bool {
versionFlag := flag.Bool("version", false, "Print version information")
flag.Parse()
if *versionFlag {
return true
} else {
return true
}
}
func ParseConfig(filepath string) (config models.TwiloDetails, success bool) {
content, err := os.ReadFile(filepath)
fmt.Println("Reading config file...")
fmt.Printf("%s\n", filepath)
if err != nil {
fmt.Println("An error reading the file")
return
}
err = json.Unmarshal(content, &config)
if err != nil {
fmt.Println("An error occurred")
return config, false
}
return config, true
}