mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 18:40:39 +00:00
Add commandline option to specify receive timeou
This commit is contained in:
parent
5accb9b02f
commit
96bd68e034
1 changed files with 10 additions and 1 deletions
|
@ -141,8 +141,14 @@ public class Main {
|
||||||
System.err.println("User is not registered.");
|
System.err.println("User is not registered.");
|
||||||
System.exit(1);
|
System.exit(1);
|
||||||
}
|
}
|
||||||
|
int timeout = ns.getInt("timeout");
|
||||||
|
boolean returnOnTimeout = true;
|
||||||
|
if (timeout < 0) {
|
||||||
|
returnOnTimeout = false;
|
||||||
|
timeout = 5;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
m.receiveMessages(5, true, new ReceiveMessageHandler(m));
|
m.receiveMessages(timeout, returnOnTimeout, new ReceiveMessageHandler(m));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
System.err.println("Error while receiving message: " + e.getMessage());
|
System.err.println("Error while receiving message: " + e.getMessage());
|
||||||
System.exit(3);
|
System.exit(3);
|
||||||
|
@ -196,6 +202,9 @@ public class Main {
|
||||||
.help("Add file as attachment");
|
.help("Add file as attachment");
|
||||||
|
|
||||||
Subparser parserReceive = subparsers.addParser("receive");
|
Subparser parserReceive = subparsers.addParser("receive");
|
||||||
|
parserReceive.addArgument("-t", "--timeout")
|
||||||
|
.type(int.class)
|
||||||
|
.help("Number of seconds to wait for new messages (negative values disable timeout)");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Namespace ns = parser.parseArgs(args);
|
Namespace ns = parser.parseArgs(args);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue