]> nmode's Git Repositories - signal-cli/commitdiff
Remove fallback to reading stdin if no message body is given
authorAsamK <asamk@gmx.de>
Tue, 21 Jun 2022 11:55:01 +0000 (13:55 +0200)
committerAsamK <asamk@gmx.de>
Sun, 28 Aug 2022 14:04:05 +0000 (16:04 +0200)
To read a message from stdin, use the `--message-from-stdin` flag

man/signal-cli.1.adoc
run_tests.sh
src/main/java/org/asamk/signal/commands/SendCommand.java

index fabca9d4f87d82b94a4713c07f24da0e2e64d68a..025ee7ffc3d71dd9313a5b819c1756eef63e365f 100644 (file)
@@ -224,7 +224,6 @@ Specify the recipient group ID in base64 encoding.
 
 *-m* MESSAGE, *--message* MESSAGE::
 Specify the message.
-Currently, signal-cli reads the message from stdin if `-m` is missing, but this will change in a future version and the explicit flag `--message-from-stdin` should be used instead.
 
 *--message-from-stdin*::
 Read the message from standard input.
index 69a7d382b8a08d20f9eb33357560bb2d98aba816..c8788cb4e0f77d9b693dd5d4447fbf043e3a7ba7 100755 (executable)
@@ -200,7 +200,7 @@ for OUTPUT in "plain-text" "json"; do
   run_main -a "$NUMBER_1" --output="$OUTPUT" send "$NUMBER_2" -m hi
   run_main -a "$NUMBER_2" --output="$OUTPUT" send "$NUMBER_1" -m hi
   run_main -a "$NUMBER_1" --output="$OUTPUT" send -g "$GROUP_ID" -m hi -a LICENSE --mention "1:1:$NUMBER_2"
-  TIMESTAMP=$(uname -a | run_main -a "$NUMBER_1" --output=json send "$NUMBER_2" | jq '.timestamp')
+  TIMESTAMP=$(uname -a | run_main -a "$NUMBER_1" --output=json send --message-from-stdin "$NUMBER_2" | jq '.timestamp')
   run_main -a "$NUMBER_2" --output="$OUTPUT" sendReaction "$NUMBER_1" -e 🍀 -a "$NUMBER_1" -t "$TIMESTAMP"
   run_main -a "$NUMBER_1" --output="$OUTPUT" remoteDelete "$NUMBER_2" -t "$TIMESTAMP"
   run_main -a "$NUMBER_2" --output="$OUTPUT" receive
index 23a7fb37667eb42b760a08eebc9f2b265f9330d3..57c0c5e9c66c6e6e1045bf118e6c430b863c6f8a 100644 (file)
@@ -120,13 +120,15 @@ public class SendCommand implements JsonRpcLocalCommand {
 
         var messageText = ns.getString("message");
         final var readMessageFromStdin = ns.getBoolean("message-from-stdin") == Boolean.TRUE;
-        if (readMessageFromStdin || (messageText == null && sticker == null)) {
+        if (readMessageFromStdin) {
             logger.debug("Reading message from stdin...");
             try {
                 messageText = IOUtils.readAll(System.in, IOUtils.getConsoleCharset());
             } catch (IOException e) {
                 throw new UserErrorException("Failed to read message from stdin: " + e.getMessage());
             }
+        } else if (messageText == null) {
+            messageText = "";
         }
 
         List<String> attachments = ns.getList("attachment");
@@ -169,7 +171,7 @@ public class SendCommand implements JsonRpcLocalCommand {
         }
 
         try {
-            var results = m.sendMessage(new Message(messageText == null ? "" : messageText,
+            var results = m.sendMessage(new Message(messageText,
                     attachments,
                     mentions,
                     Optional.ofNullable(quote),