@@ -3,6 +3,8 @@ import cligen
33from os import getCurrentProcessId
44from strutils import split
55
6+ import utils/ version
7+
68include " nmqtt.nim"
79
810
@@ -67,44 +69,53 @@ proc nmqttSub(host="127.0.0.1", port=1883, ssl=false, clientid="", username="",
6769
6870when isMainModule :
6971
70- let topLvlUse = """ ${doc}
72+ let topLvlUse = """ nmqtt_sub is a MQTT client that will subscribe to a topic on a MQTT-broker.
73+ nmqtt_sub is based upon nmqtt version """ & nmqttVersion & """
74+
75+
7176Usage:
7277 $command [options] -t {topic}
7378 $command [-h host -p port -u username -P password] -t {topic}
7479
7580OPTIONS
7681$options
7782"""
78- # clCfg.hTabCols = @[clOptKeys, clDflVal, clDescrip]
7983 clCfg.hTabCols = @ [clOptKeys, clDescrip]
80- dispatch (nmqttSub,
84+ dispatchGen (nmqttSub,
8185 doc= " Subscribe to a topic on a MQTT-broker." ,
8286 cmdName= " nmqtt_sub" ,
8387 help= {
8488 " host" : " IP-address of the broker. Defaults to 127.0.0.1" ,
8589 " port" : " network port to connect too. Defaults to 1883." ,
86- " ssl" : " enable ssl. Auto-enabled on port 8883 ." ,
87- " clientid" : " your connection ID. Defaults to nmqtt_pub_ appended with processID." ,
90+ " ssl" : " use ssl." ,
91+ " clientid" : " your connection ID. Defaults to nmqttsub- appended with processID." ,
8892 " username" : " provide a username" ,
8993 " password" : " provide a password" ,
90- " topic" : " MQTT topic to publish to ." ,
94+ " topic" : " MQTT topic to subscribe too. For multipe topics, separate them by comma ." ,
9195 " qos" : " quality of service level to use for all messages. Defaults to 0." ,
9296 " keepalive" : " keep alive in seconds for this client. Defaults to 60." ,
9397 " removeretained" : " clear any retained messages on the topic" ,
9498 " willtopic" : " set the will's topic" ,
9599 " willmsg" : " set the will's message" ,
96100 " willqos" : " set the will's quality of service" ,
97- " willretain" : " set to retain the will message"
101+ " willretain" : " set to retain the will message" ,
102+ " verbosity" : " set the verbosity level from 0-2. Defaults to 0."
98103 },
99104 short= {
100105 " password" : 'P' ,
101106 " help" : '?' ,
102107 " ssl" : '\0 ' ,
108+ " verbosity" : 'v' ,
103109 " willtopic" : '\0 ' ,
104110 " willmsg" : '\0 ' ,
105111 " willqos" : '\0 ' ,
106112 " willretain" : '\0 ' ,
107113 " removeretained" : '\0 '
108114 },
109- usage= topLvlUse
110- )
115+ usage= topLvlUse,
116+ dispatchName= " subscriber"
117+ )
118+
119+ cligenQuit subscriber (skipHelp= true )
120+
121+ runForever ()
0 commit comments