1
0
Fork 0
mirror of https://github.com/Luzifer/mqttcli.git synced 2024-11-08 14:50:11 +00:00
Small CLI util to interface with a MQTT server
Find a file
Knut Ahlers 2e45fb4b9b
Upgrade dependencies
Signed-off-by: Knut Ahlers <knut@ahlers.me>
2022-02-07 13:39:10 +01:00
.gitignore Initial version 2019-07-29 23:24:38 +02:00
.repo-runner.yaml Add auto-building 2019-08-01 19:48:00 +02:00
go.mod Upgrade dependencies 2022-02-07 13:39:10 +01:00
go.sum Upgrade dependencies 2022-02-07 13:39:10 +01:00
History.md prepare release v0.1.0 2019-08-01 19:49:58 +02:00
LICENSE Add meta files 2019-07-29 23:40:48 +02:00
main.go Fix: Set client id 2022-02-07 13:36:11 +01:00
Makefile Add auto-building 2019-08-01 19:48:00 +02:00
mqtt.go Fix: Print newline after each CSV line 2019-07-29 23:27:58 +02:00
README.md Add meta files 2019-07-29 23:40:48 +02:00

Go Report Card

Luzifer / mqttcli

mqttcli is a small CLI util to interface with a MQTT server. It can be used to publish messages to oder subscribe messages from a MQTT server.

At the moment it is intended to connect to simple setups using plain tcp, ssl with trusted certificates or websockets (ws). More options to come later.

Usage

# mqttcli --help
Usage of mqttcli:
      --log-level string        Log level (debug, info, warn, error, fatal) (default "info")
  -m, --message string          
  -b, --mqtt-broker string      Broker URI to connect to scheme://host:port (scheme is one of 'tcp', 'ssl', or 'ws') (default "tcp://localhost:1883")
      --mqtt-client-id string   Client ID to use when connecting, must be unique (default "21064ab7-c296-445e-b8b6-d1bced77853c")
  -p, --mqtt-pass string        Password to identify against the broker
      --mqtt-timeout duration   How long to wait for the client to complete operations (default 10s)
  -u, --mqtt-user string        Username to identify against the broker
  -o, --output-format string    How to ouptut received messages (One of 'log', 'csv', 'jsonl') (default "log")
      --qos int                 QOS to use (0 - Only Once, 1 - At Least Once, 2 - Only Once) (default 1)
      --retain                  Retain message on topic
  -t, --topic strings           Topic to subscribe / publish to
      --version                 Prints current version and exits

Examples

# envrun -- mqttcli sub -t 'mysensor/+'
INFO[0001] Message received                              message=4058 qos=1 retained=false topic=mysensor/co2

# envrun -- mqttcli sub -t 'mysensor/+' -o csv
Topic,QOS,Retained,Message
mysensor/co2,1,false,"3978"

# envrun -- mqttcli sub -t 'mysensor/+' -o jsonl
{"topic":"mysensor/co2","qos":1,"retained":false,"message":"3972"}
# envrun -- mqttcli pub -t mysensor/test -m 'ohai?'

# envrun -- mqttcli sub -t 'mysensor/+'
INFO[0001] Message received                              message="ohai?" qos=1 retained=false topic=mysensor/test