Search in sources :

Example 1 with UpdateOperationOptions

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;
}
Also used : UpdateOperationOptions(org.syncany.operations.update.UpdateOperationOptions) UpdateOperationResult(org.syncany.operations.update.UpdateOperationResult) UpdateOperation(org.syncany.operations.update.UpdateOperation)

Example 2 with UpdateOperationOptions

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;
}
Also used : UpdateOperationOptions(org.syncany.operations.update.UpdateOperationOptions) UpdateOperationAction(org.syncany.operations.update.UpdateOperationAction) OptionSet(joptsimple.OptionSet) OptionParser(joptsimple.OptionParser)

Example 3 with UpdateOperationOptions

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());
}
Also used : UpdateOperationOptions(org.syncany.operations.update.UpdateOperationOptions) UpdateOperationResult(org.syncany.operations.update.UpdateOperationResult) UpdateOperation(org.syncany.operations.update.UpdateOperation) Test(org.junit.Test)

Aggregations

UpdateOperationOptions (org.syncany.operations.update.UpdateOperationOptions)3 UpdateOperation (org.syncany.operations.update.UpdateOperation)2 UpdateOperationResult (org.syncany.operations.update.UpdateOperationResult)2 OptionParser (joptsimple.OptionParser)1 OptionSet (joptsimple.OptionSet)1 Test (org.junit.Test)1 UpdateOperationAction (org.syncany.operations.update.UpdateOperationAction)1