Skip to content

Commit

Permalink
feat(cli): line mode option support
Browse files Browse the repository at this point in the history
  • Loading branch information
ysfscream authored and Red-Asuka committed Dec 4, 2024
1 parent dcd8435 commit 4039ead
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ export class Commander {
.option('-d, --dup', 'mark as duplicate flag')
.option('-s, --stdin', 'read the message body from stdin')
.option('-M, --multiline', 'read lines from stdin as multiple messages')
.option('-lm, --line-mode', 'enter interactive mode to send messages line by line (equivalent to -s -M)', false)
// properties options of MQTT 5.0
.option('-pf, --payload-format-indicator', 'the payload format indicator of the publish message')
.option('-e, --message-expiry-interval <NUMBER>', 'the lifetime of the publish message in seconds', parseNumber)
Expand Down
5 changes: 5 additions & 0 deletions cli/src/lib/pub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,11 @@ const pub = (options: PublishOptions) => {

checkTopicExists(options.topic, 'pub')

if (options.lineMode) {
options.multiline = true
options.stdin = true
}

const connOpts = parseConnectOptions(options, 'pub')

const pubOpts = parsePublishOptions(options)
Expand Down
1 change: 1 addition & 0 deletions cli/src/types/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ declare global {
fileRead?: string
stdin?: boolean
multiline?: boolean
lineMode?: boolean
// properties of MQTT 5.0
payloadFormatIndicator?: boolean
messageExpiryInterval?: number
Expand Down

0 comments on commit 4039ead

Please sign in to comment.