import org.asamk.signal.DbusReceiveMessageHandler;
import org.asamk.signal.JsonDbusReceiveMessageHandler;
import org.asamk.signal.OutputType;
+import org.asamk.signal.commands.exceptions.CommandException;
+import org.asamk.signal.commands.exceptions.UnexpectedErrorException;
import org.asamk.signal.dbus.DbusSignalImpl;
import org.asamk.signal.manager.Manager;
import org.freedesktop.dbus.connections.impl.DBusConnection;
@Override
public void attachToSubparser(final Subparser subparser) {
+ subparser.help("Run in daemon mode and provide an experimental dbus interface.");
subparser.addArgument("--system")
.action(Arguments.storeTrue())
.help("Use DBus system bus instead of user bus.");
subparser.addArgument("--ignore-attachments")
.help("Don’t download attachments of received messages.")
.action(Arguments.storeTrue());
- subparser.addArgument("--json")
- .help("WARNING: This parameter is now deprecated! Please use the global \"--output=json\" option instead.\n\nOutput received messages in json format, one json object per line.")
- .action(Arguments.storeTrue());
}
@Override
}
@Override
- public int handleCommand(final Namespace ns, final Manager m) {
- var inJson = ns.get("output") == OutputType.JSON || ns.getBoolean("json");
-
- // TODO delete later when "json" variable is removed
- if (ns.getBoolean("json")) {
- logger.warn("\"--json\" option has been deprecated, please use the global \"--output=json\" instead.");
- }
+ public void handleCommand(final Namespace ns, final Manager m) throws CommandException {
+ var inJson = ns.get("output") == OutputType.JSON;
- boolean ignoreAttachments = ns.getBoolean("ignore_attachments");
+ boolean ignoreAttachments = ns.getBoolean("ignore-attachments");
DBusConnection.DBusBusType busType;
if (ns.getBoolean("system")) {
t.join();
} catch (InterruptedException ignored) {
}
- return 0;
} catch (DBusException | IOException e) {
logger.error("Dbus command failed", e);
- return 2;
+ throw new UnexpectedErrorException("Dbus command failed");
}
}
@Override
- public int handleCommand(final Namespace ns, final List<Manager> managers) {
- var inJson = ns.get("output") == OutputType.JSON || ns.getBoolean("json");
-
- // TODO delete later when "json" variable is removed
- if (ns.getBoolean("json")) {
- logger.warn("\"--json\" option has been deprecated, please use the global \"--output=json\" instead.");
- }
+ public void handleCommand(final Namespace ns, final List<Manager> managers) throws CommandException {
+ var inJson = ns.get("output") == OutputType.JSON;
- boolean ignoreAttachments = ns.getBoolean("ignore_attachments");
+ boolean ignoreAttachments = ns.getBoolean("ignore-attachments");
DBusConnection.DBusBusType busType;
if (ns.getBoolean("system")) {
} catch (InterruptedException ignored) {
}
}
- return 0;
} catch (DBusException | IOException e) {
logger.error("Dbus command failed", e);
- return 2;
+ throw new UnexpectedErrorException("Dbus command failed");
}
}