diff --git a/cli/cli.go b/cli/cli.go index 7cfaa8f..9d5a18c 100644 --- a/cli/cli.go +++ b/cli/cli.go @@ -61,7 +61,7 @@ func HandleExit(p service.Part) { }() } -func InitMqttFlags(defaultClientId string, mqttBroker, username, password, clientId *string, mqttQos *int, mqttRetain *bool) { +func InitMqttFlagSet(flagSet *flag.FlagSet, defaultClientId string, mqttBroker, username, password, clientId *string, mqttQos *int, mqttRetain *bool) { SetDefaultValueFromEnv(clientId, "MQTT_CLIENT_ID", defaultClientId) SetDefaultValueFromEnv(mqttBroker, "MQTT_BROKER", "tcp://127.0.0.1:1883") @@ -73,6 +73,10 @@ func InitMqttFlags(defaultClientId string, mqttBroker, username, password, clien flag.BoolVar(mqttRetain, "mqtt-retain", *mqttRetain, "Retain mqtt message, if not set, true if MQTT_RETAIN env variable is set") } +func InitMqttFlags(defaultClientId string, mqttBroker, username, password, clientId *string, mqttQos *int, mqttRetain *bool) { + InitMqttFlagSet(flag.CommandLine, defaultClientId, mqttBroker, username, password, clientId, mqttQos, mqttRetain) +} + func InitIntFlag(key string, defValue int) int { var value int err := SetIntDefaultValueFromEnv(&value, key, defValue)