From 90ac69cc33cad961e5dfc05c8e9bf7bf7158afea Mon Sep 17 00:00:00 2001 From: ni00 Date: Wed, 28 Jun 2023 16:38:28 +0800 Subject: [PATCH] docs(cli):update docs about ws and protobuf support --- cli/README-CN.md | 14 +++++++++++--- cli/README.md | 14 +++++++++++--- cli/src/index.ts | 36 ++++++++++++++++++++++++------------ 3 files changed, 46 insertions(+), 18 deletions(-) diff --git a/cli/README-CN.md b/cli/README-CN.md index a1d8dc1eed..329d6e51c7 100644 --- a/cli/README-CN.md +++ b/cli/README-CN.md @@ -188,7 +188,8 @@ mqttx conn --help | -k, --keepalive | MQTT 的 Keep Alive,默认为 30 | | -u, --username | 连接到 MQTT Broker 的用户名 | | -P, --password | 连接到 MQTT Broker 的密码 | -| -l, --protocol | 连接时的协议,mqtt 或 mqtts,默认为 mqtt | +| -l, --protocol | 连接时的协议,支持 mqtt、mqtts、ws、wss,默认为 mqtt | +| --path | websocket 的路径,默认为 /mqtt | | --key | key 文件的路径 | | --cert | cert 文件的路径 | | --ca | ca 证书的文件路径 | @@ -235,7 +236,8 @@ mqttx sub --help | -k, --keepalive | MQTT 的 Keep Alive,默认为 30 | | -u, --username | 连接到 MQTT Broker 的用户名 | | -P, --password | 连接到 MQTT Broker 的密码 | -| -l, --protocol | 连接时的协议,mqtt 或 mqtts,默认为 mqtt | +| -l, --protocol | 连接时的协议,支持 mqtt、mqtts、ws、wss,默认为 mqtt | +| --path | websocket 的路径,默认为 /mqtt | | -nl, --no_local | MQTT 5.0 订阅选项中的 no local 标识 | | -rap, --retain-as-published | MQTT 5.0 订阅选项中的 retain as published 标识 | | -rh, --retain-handling <0/1/2> | MQTT 5.0 订阅选项中的 retain handling 标识 | @@ -271,6 +273,8 @@ mqttx sub --help | --save \[PATH\] | 将参数保存到本地配置文件中,文件支持 json 和 yaml 格式,默认路径为 ./mqttx-cli-config.json | | --config \[PATH\] | 从本地配置文件加载参数,文件支持 json 和 yaml 格式,默认路径为 ./mqttx-cli-config.json | | --help | 展示 sub 命令的帮助信息 | +| -Pp, --protobuf-path | 定义 Protocol Buffers(protobuf)消息格式的 .proto 文件路径 | +| -Pmn, --protobuf-message-name | Protobuf 消息类型的名称(必须存在于 .proto 文件中) | ### 发布 @@ -293,7 +297,9 @@ mqttx pub --help | -M, --multiline | 可以通过多行发布多条消息 | | -u, --username | 连接到 MQTT Broker 的用户名 | | -P, --password | 连接到 MQTT Broker 的密码 | -| -l, --protocol | 连接时的协议,mqtt 或 mqtts,默认为 mqtt | +| -f, --format | 输入消息的格式类型,支持 base64、json 和 hex | +| -l, --protocol | 连接时的协议,支持 mqtt、mqtts、ws、wss,默认为 mqtt | +| --path | websocket 的路径,默认为 /mqtt | | --key | key 文件的路径 | | --cert | cert 文件的路径 | | --ca | ca 证书的文件路径 | @@ -329,6 +335,8 @@ mqttx pub --help | --save \[PATH\] | 将参数保存到本地配置文件中,文件支持 json 和 yaml 格式,默认路径为 ./mqttx-cli-config.json | | --config \[PATH\] | 从本地配置文件加载参数,文件支持 json 和 yaml 格式,默认路径为 ./mqttx-cli-config.json | | --help | 展示 pub 命令的帮助信息 | +| -Pp, --protobuf-path | 定义 Protocol Buffers(protobuf)消息格式的 .proto 文件路径 | +| -Pmn, --protobuf-message-name | Protobuf 消息类型的名称(必须存在于 .proto 文件中) | ### 性能测试 diff --git a/cli/README.md b/cli/README.md index c4c40fd937..9ec797338b 100644 --- a/cli/README.md +++ b/cli/README.md @@ -185,7 +185,8 @@ mqttx conn --help | -k, --keepalive | send a ping every SEC seconds (default: 30) | | -u, --username | the username | | -P, --password | the password | -| -l, --protocol | the protocol to use, mqtt or mqtts (default: mqtt) | +| -l, --protocol | the protocol to use, mqtt, mqtts, ws, or wss (default: mqtt) | +| --path | the path of websocket (default: /mqtt) | | --key | path to the key file | | --cert | path to the cert file | | --ca | path to the ca certificate | @@ -232,7 +233,8 @@ mqttx sub --help | -k, --keepalive | send a ping every SEC seconds (default: 30) | | -u, --username | the username | | -P, --password | the password | -| -l, --protocol | the protocol to use, mqtt or mqtts (default: mqtt) | +| -l, --protocol | the protocol to use, mqtt, mqtts, ws, or wss (default: mqtt) | +| --path | the path of websocket (default: /mqtt) | | -nl, --no_local | the no local MQTT 5.0 flag | | -rap, --retain-as-published | the retain as published MQTT 5.0 flag | | -rh, --retain-handling <0/1/2> | the retain handling MQTT 5.0 | @@ -268,6 +270,8 @@ mqttx sub --help | --save \[PATH\] | save the parameters to the local configuration file, which supports json and yaml format, default path is `./mqttx-cli-config.json` | | --config \[PATH\] | load the parameters from the local configuration file, which supports json and yaml format, default path is `./mqttx-cli-config.json` | | --help | display help for sub command | +| -Pp, --protobuf-path | the path to the .proto file that defines the message format for Protocol Buffers (protobuf) | +| -Pmn, --protobuf-message-name | the name of the protobuf message type (must exist in the .proto file) | ### Publish @@ -290,7 +294,9 @@ mqttx pub --help | -M, --multiline | read lines from stdin as multiple messages | | -u, --username | the username | | -P, --password | the password | -| -l, --protocol | the protocol to use, mqtt or mqtts (default: mqtt) | +| -f, --format | the format type of the input message, support base64, json, hex | +| -l, --protocol | the protocol to use, mqtt, mqtts, ws, or wss (default: mqtt) | +| --path | the path of websocket (default: /mqtt) | | --key | path to the key file | | --cert | path to the cert file | | --ca | path to the ca certificate | @@ -326,6 +332,8 @@ mqttx pub --help | --save \[PATH\] | save the parameters to the local configuration file, which supports json and yaml format, default path is `./mqttx-cli-config.json` | | --config \[PATH\] | load the parameters from the local configuration file, which supports json and yaml format, default path is `./mqttx-cli-config.json` | | --help | display help for pub command | +| -Pp, --protobuf-path | the path to the .proto file that defines the message format for Protocol Buffers (protobuf) | +| -Pmn, --protobuf-message-name | the name of the protobuf message type (must exist in the .proto file) | ### Benchmark diff --git a/cli/src/index.ts b/cli/src/index.ts index fbae9a7f61..4c183f23cd 100755 --- a/cli/src/index.ts +++ b/cli/src/index.ts @@ -53,7 +53,7 @@ export class Commander { .option('-k, --keepalive ', 'send a ping every SEC seconds', parseNumber, 30) .option('-u, --username ', 'the username') .option('-P, --password ', 'the password') - .option('-l, --protocol ', 'the protocol to use, mqtt or mqtts', parseProtocol, 'mqtt') + .option('-l, --protocol ', 'the protocol to use, mqtt, mqtts, ws, or wss', parseProtocol, 'mqtt') .option('--path ', 'the path of websocket', '/mqtt') .option('--key ', 'path to the key file') .option('--cert ', 'path to the cert file') @@ -140,12 +140,13 @@ export class Commander { .option('-V, --mqtt-version <5/3.1.1/3.1>', 'the MQTT version', parseMQTTVersion, 5) .option('-h, --hostname ', 'the broker host', 'localhost') .option('-p, --port ', 'the broker port', parseNumber) + .option('-f, --format ', 'the format type of the input message, support base64, json, hex', parseFormat) .option('-i, --client-id ', 'the client id', getClientId()) .option('--no-clean', 'set the clean session flag to false', true) .option('-k, --keepalive ', 'send a ping every SEC seconds', parseNumber, 30) .option('-u, --username ', 'the username') .option('-P, --password ', 'the password') - .option('-l, --protocol ', 'the protocol to use, mqtt or mqtts', parseProtocol, 'mqtt') + .option('-l, --protocol ', 'the protocol to use, mqtt, mqtts, ws, or wss', parseProtocol, 'mqtt') .option('--path ', 'the path of websocket', '/mqtt') .option('--key ', 'path to the key file') .option('--cert ', 'path to the cert file') @@ -195,9 +196,14 @@ export class Commander { '--config [PATH]', 'load the parameters from the local configuration file, which supports json and yaml format, default path is ./mqttx-cli-config.json', ) - .option('-Pp, --protobuf-path ', 'the .proto file that defines the message format of protobuf') - .option('-Pmn, --protobuf-message-name ', 'the name of the protobuf message type') - .option('-f, --format ', 'the format type of the input message, support base64, json, hex', parseFormat) + .option( + '-Pp, --protobuf-path ', + 'the path to the .proto file that defines the message format for Protocol Buffers (protobuf)', + ) + .option( + '-Pmn, --protobuf-message-name ', + 'the name of the protobuf message type (must exist in the .proto file)', + ) .allowUnknownOption(false) .action(pub) @@ -237,7 +243,7 @@ export class Commander { .option('-u, --username ', 'the username') .option('-P, --password ', 'the password') - .option('-l, --protocol ', 'the protocol to use, mqtt or mqtts', parseProtocol, 'mqtt') + .option('-l, --protocol ', 'the protocol to use, mqtt, mqtts, ws, or wss', parseProtocol, 'mqtt') .option('--path ', 'the path of websocket', '/mqtt') .option('--key ', 'path to the key file') .option('--cert ', 'path to the cert file') @@ -287,8 +293,14 @@ export class Commander { '--config [PATH]', 'load the parameters from the local configuration file, which supports json and yaml format, default path is ./mqttx-cli-config.json', ) - .option('-Pp, --protobuf-path ', 'the .proto file that defines the message format of protobuf') - .option('-Pmn, --protobuf-message-name ', 'the name of the protobuf message type') + .option( + '-Pp, --protobuf-path ', + 'the path to the .proto file that defines the message format for Protocol Buffers (protobuf)', + ) + .option( + '-Pmn, --protobuf-message-name ', + 'the name of the protobuf message type (must exist in the .proto file)', + ) .allowUnknownOption(false) .action(sub) @@ -307,7 +319,7 @@ export class Commander { .option('-k, --keepalive ', 'send a ping every SEC seconds', parseNumber, 30) .option('-u, --username ', 'the username') .option('-P, --password ', 'the password') - .option('-l, --protocol ', 'the protocol to use, mqtt or mqtts', parseProtocol, 'mqtt') + .option('-l, --protocol ', 'the protocol to use, mqtt, mqtts, ws, or wss', parseProtocol, 'mqtt') .option('--path ', 'the path of websocket', '/mqtt') .option('--key ', 'path to the key file') .option('--cert ', 'path to the cert file') @@ -405,7 +417,7 @@ export class Commander { .option('-k, --keepalive ', 'send a ping every SEC seconds', parseNumber, 30) .option('-u, --username ', 'the username') .option('-P, --password ', 'the password') - .option('-l, --protocol ', 'the protocol to use, mqtt or mqtts', parseProtocol, 'mqtt') + .option('-l, --protocol ', 'the protocol to use, mqtt, mqtts, ws, or wss', parseProtocol, 'mqtt') .option('--path ', 'the path of websocket', '/mqtt') .option('--key ', 'path to the key file') .option('--cert ', 'path to the cert file') @@ -492,7 +504,7 @@ export class Commander { .option('-u, --username ', 'the username') .option('-P, --password ', 'the password') - .option('-l, --protocol ', 'the protocol to use, mqtt or mqtts', parseProtocol, 'mqtt') + .option('-l, --protocol ', 'the protocol to use, mqtt, mqtts, ws, or wss', parseProtocol, 'mqtt') .option('--path ', 'the path of websocket', '/mqtt') .option('--key ', 'path to the key file') .option('--cert ', 'path to the cert file') @@ -592,7 +604,7 @@ export class Commander { .option('-k, --keepalive ', 'send a ping every SEC seconds', parseNumber, 30) .option('-u, --username ', 'the username') .option('-P, --password ', 'the password') - .option('-l, --protocol ', 'the protocol to use, mqtt or mqtts', parseProtocol, 'mqtt') + .option('-l, --protocol ', 'the protocol to use, mqtt, mqtts, ws, or wss', parseProtocol, 'mqtt') .option('--path ', 'the path of websocket', '/mqtt') .option('--key ', 'path to the key file') .option('--cert ', 'path to the cert file')