Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(cli): display from topic & qos in sub #1592

Merged
merged 1 commit into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ export class Commander {
parseUserProperties,
)
.option('-f, --format <TYPE>', 'format the message body, support base64, json, hex and cbor', parseFormat)
.option('-v, --verbose', 'print the topic before the message')
.option('-v, --verbose', 'turn on verbose mode to display incoming MQTT packets')
.option(
'--output-mode <default/clean>',
'choose between the default and clean mode, which outputs the complete MQTT packet data, allowing users to pipe the output as they wish',
Expand Down
9 changes: 6 additions & 3 deletions cli/src/lib/sub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,16 @@ const sub = (options: SubscribeOptions) => {

const msgData: Record<string, unknown>[] = []

options.verbose && msgData.push({ label: 'topic', value: topic })
options.verbose && msgData.push({ label: 'mqtt-packet', value: packet })

let receivedMessage = processReceivedMessage(payload, protobufPath, protobufMessageName, format)
msgData.push({ label: 'payload', value: receivedMessage })
msgData.push({ label: 'topic', value: topic })
msgData.push({ label: 'qos', value: packet.qos })

packet.retain && msgData.push({ label: 'retain', value: packet.retain })

let receivedMessage = processReceivedMessage(payload, protobufPath, protobufMessageName, format)
msgData.push({ label: 'payload', value: receivedMessage })

if (packet.properties?.userProperties) {
const up: { key: string; value: string }[] = []
Object.entries(packet.properties.userProperties).forEach(([key, value]) => {
Expand Down
Loading