mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 18:40:39 +00:00
Add --service-environment to allow testing against sandbox environment
This commit is contained in:
parent
726103d138
commit
db756bfe10
2 changed files with 29 additions and 5 deletions
|
@ -55,7 +55,7 @@ public class App {
|
||||||
parser.addArgument("--config")
|
parser.addArgument("--config")
|
||||||
.help("Set the path, where to store the config (Default: $XDG_DATA_HOME/signal-cli , $HOME/.local/share/signal-cli).");
|
.help("Set the path, where to store the config (Default: $XDG_DATA_HOME/signal-cli , $HOME/.local/share/signal-cli).");
|
||||||
|
|
||||||
parser.addArgument("-u", "--username").help("Specify your phone number, that will be used for verification.");
|
parser.addArgument("-u", "--username").help("Specify your phone number, that will be your identifier.");
|
||||||
|
|
||||||
var mut = parser.addMutuallyExclusiveGroup();
|
var mut = parser.addMutuallyExclusiveGroup();
|
||||||
mut.addArgument("--dbus").help("Make request via user dbus.").action(Arguments.storeTrue());
|
mut.addArgument("--dbus").help("Make request via user dbus.").action(Arguments.storeTrue());
|
||||||
|
@ -66,6 +66,11 @@ public class App {
|
||||||
.type(Arguments.enumStringType(OutputType.class))
|
.type(Arguments.enumStringType(OutputType.class))
|
||||||
.setDefault(OutputType.PLAIN_TEXT);
|
.setDefault(OutputType.PLAIN_TEXT);
|
||||||
|
|
||||||
|
parser.addArgument("--service-environment")
|
||||||
|
.help("Choose the server environment to use, SANDBOX or LIVE.")
|
||||||
|
.type(Arguments.enumStringType(ServiceEnvironmentCli.class))
|
||||||
|
.setDefault(ServiceEnvironmentCli.LIVE);
|
||||||
|
|
||||||
var subparsers = parser.addSubparsers().title("subcommands").dest("command");
|
var subparsers = parser.addSubparsers().title("subcommands").dest("command");
|
||||||
|
|
||||||
final var commands = Commands.getCommands();
|
final var commands = Commands.getCommands();
|
||||||
|
@ -88,15 +93,15 @@ public class App {
|
||||||
throw new UserErrorException("Command not implemented!");
|
throw new UserErrorException("Command not implemented!");
|
||||||
}
|
}
|
||||||
|
|
||||||
OutputType outputType = ns.get("output");
|
var outputType = ns.<OutputType>get("output");
|
||||||
if (!command.getSupportedOutputTypes().contains(outputType)) {
|
if (!command.getSupportedOutputTypes().contains(outputType)) {
|
||||||
throw new UserErrorException("Command doesn't support output type " + outputType.toString());
|
throw new UserErrorException("Command doesn't support output type " + outputType.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
var username = ns.getString("username");
|
var username = ns.getString("username");
|
||||||
|
|
||||||
final boolean useDbus = ns.getBoolean("dbus");
|
final var useDbus = ns.getBoolean("dbus");
|
||||||
final boolean useDbusSystem = ns.getBoolean("dbus_system");
|
final var useDbusSystem = ns.getBoolean("dbus_system");
|
||||||
if (useDbus || useDbusSystem) {
|
if (useDbus || useDbusSystem) {
|
||||||
// If username is null, it will connect to the default object path
|
// If username is null, it will connect to the default object path
|
||||||
initDbusClient(command, username, useDbusSystem);
|
initDbusClient(command, username, useDbusSystem);
|
||||||
|
@ -111,7 +116,10 @@ public class App {
|
||||||
dataPath = getDefaultDataPath();
|
dataPath = getDefaultDataPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
final var serviceEnvironment = ServiceEnvironment.LIVE;
|
final var serviceEnvironmentCli = ns.<ServiceEnvironmentCli>get("service_environment");
|
||||||
|
final var serviceEnvironment = serviceEnvironmentCli == ServiceEnvironmentCli.LIVE
|
||||||
|
? ServiceEnvironment.LIVE
|
||||||
|
: ServiceEnvironment.SANDBOX;
|
||||||
|
|
||||||
if (!ServiceConfig.getCapabilities().isGv2()) {
|
if (!ServiceConfig.getCapabilities().isGv2()) {
|
||||||
logger.warn("WARNING: Support for new group V2 is disabled,"
|
logger.warn("WARNING: Support for new group V2 is disabled,"
|
||||||
|
|
16
src/main/java/org/asamk/signal/ServiceEnvironmentCli.java
Normal file
16
src/main/java/org/asamk/signal/ServiceEnvironmentCli.java
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
package org.asamk.signal;
|
||||||
|
|
||||||
|
public enum ServiceEnvironmentCli {
|
||||||
|
LIVE {
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "live";
|
||||||
|
}
|
||||||
|
},
|
||||||
|
SANDBOX {
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "sandbox";
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue