Skipped reading of config file if all connection parameters are specified via command line arguments.

http_upload
Martin Dosch 5 years ago
parent c845972b1f
commit f61c0edda0

@ -157,8 +157,8 @@ func readMessage(messageFilePath string) (string, error) {
func main() {
var (
err error
message string
err error
message, user, server, password string
)
// Define command line flags.
@ -205,20 +205,6 @@ func main() {
recipients[i] = validatedJid
}
// Read configuration from file.
config, err := parseConfig(*flagFile)
if err != nil {
log.Println("Error parsing ", *flagFile, ": ", err)
}
// Set connection options according to config.
user := config.username
server := config.jserver
password := config.password
if config.port != "" {
server = server + ":" + config.port
}
// Overwrite user if specified via command line flag.
if *flagUser != "" {
user = *flagUser
@ -234,6 +220,21 @@ func main() {
password = *flagPassword
}
if *flagUser == "" || *flagServer == "" || *flagPassword == "" {
// Read configuration from file.
config, err := parseConfig(*flagFile)
if err != nil {
log.Println("Error parsing ", *flagFile, ": ", err)
}
// Set connection options according to config.
user = config.username
server = config.jserver
password = config.password
if config.port != "" {
server = server + ":" + config.port
}
}
// Set XMPP connection options.
options := xmpp.Options{
Host: server,

Loading…
Cancel
Save