use of org.syncany.operations.update.UpdateOperationOptions in project syncany by syncany.
the class UpdateCommand method execute.
@Override
public int execute(String[] operationArgs) throws Exception {
UpdateOperationOptions operationOptions = parseOptions(operationArgs);
UpdateOperationResult operationResult = new UpdateOperation(config, operationOptions).execute();
printResults(operationResult);
return 0;
}
use of org.syncany.operations.update.UpdateOperationOptions in project syncany by syncany.
the class UpdateCommand method parseOptions.
@Override
public UpdateOperationOptions parseOptions(String[] operationArgs) throws Exception {
UpdateOperationOptions operationOptions = new UpdateOperationOptions();
OptionParser parser = new OptionParser();
OptionSpec<Void> optionSnapshots = parser.acceptsAll(asList("s", "snapshot", "snapshots"));
OptionSpec<String> optionApiEndpoint = parser.acceptsAll(asList("a", "api-endpoint")).withRequiredArg();
OptionSet options = parser.parse(operationArgs);
// Action
List<?> nonOptionArgs = options.nonOptionArguments();
if (nonOptionArgs.size() == 0) {
throw new Exception("Invalid syntax, please specify an action (check).");
}
// <action>
String actionStr = nonOptionArgs.get(0).toString();
UpdateOperationAction action = parseAction(actionStr);
operationOptions.setAction(action);
// --snapshots
operationOptions.setSnapshots(options.has(optionSnapshots));
// --api-endpoint
if (options.has(optionApiEndpoint)) {
operationOptions.setApiEndpoint(options.valueOf(optionApiEndpoint));
}
return operationOptions;
}
use of org.syncany.operations.update.UpdateOperationOptions in project syncany by syncany.
the class UpdateOperationTest method testUpdateCheck.
@Test
public void testUpdateCheck() throws Exception {
UpdateOperationOptions updateOptions = new UpdateOperationOptions();
updateOptions.setAction(UpdateOperationAction.CHECK);
// Run
UpdateOperationResult updateResult = new UpdateOperation(null, updateOptions).execute();
// Test
assertNotNull(updateResult);
assertEquals(UpdateResultCode.OK, updateResult.getResultCode());
assertEquals(UpdateOperationAction.CHECK, updateResult.getAction());
assertNotNull(updateResult.getAppInfo());
assertNotNull(updateResult.getAppInfo().getAppVersion());
assertNotNull(updateResult.getAppInfo().getArchitecture());
assertNotNull(updateResult.getAppInfo().getDate());
assertNotNull(updateResult.getAppInfo().getDist());
assertNotNull(updateResult.getAppInfo().getDownloadUrl());
assertNotNull(updateResult.getAppInfo().getOperatingSystem());
assertNotNull(updateResult.getAppInfo().getType());
}
Aggregations