- if (command instanceof ProvisioningCommand c) {
- if (account != null) {
- throw new UserErrorException("You cannot specify a account (phone number) when linking");
- }
-
- handleProvisioningCommand(c, dBusConn, outputWriter);
- return;
- }
-
- if (account == null && command instanceof MultiLocalCommand c) {
- handleMultiLocalCommand(c, dBusConn, outputWriter);
- return;
- }
- if (account != null && command instanceof RegistrationCommand c) {
- handleRegistrationCommand(c, account, dBusConn, outputWriter);
- return;
- }
- if (!(command instanceof LocalCommand localCommand)) {
- throw new UserErrorException("Command only works in multi-account mode");
- }
-
- var accountObjectPath = account == null ? tryGetSingleAccountObjectPath(dBusConn) : null;
- if (accountObjectPath == null) {
- accountObjectPath = DbusConfig.getObjectPath(account);
- }
- handleLocalCommand(localCommand, accountObjectPath, dBusConn, outputWriter);
+ DbusCommandHandler.handleCommand(command, account, dBusConn, commandHandler);