1
0
mirror of https://github.com/shirou/mqttcli.git synced 2025-04-26 13:49:17 +08:00

if host and port specified, not read from file.

This commit is contained in:
Shirou WAKAYAMA 2014-10-17 14:41:29 +09:00
parent a1c7c40724
commit e6d0151ae9

View File

@ -76,7 +76,12 @@ func getRandomClientId() string {
func NewOption(c *cli.Context) *MQTT.ClientOptions {
opts := MQTT.NewClientOptions()
getSettingsFromFile(c.String("conf"), opts)
host := c.String("host")
port := c.Int("p")
if host == "" && port == 0 {
getSettingsFromFile(c.String("conf"), opts)
}
clientId := c.String("i")
if clientId == "" {
@ -104,8 +109,6 @@ func NewOption(c *cli.Context) *MQTT.ClientOptions {
opts.SetPassword(password)
}
host := c.String("host")
port := c.Int("p")
if host != "" {
brokerUri := fmt.Sprintf("%s://%s:%d", scheme, host, port)
log.Infof("Broker URI: %s", brokerUri)