Search in sources :

Example 1 with DownOperationOptions

use of org.syncany.operations.down.DownOperationOptions in project syncany by syncany.

the class DownCommand method parseOptions.

public DownOperationOptions parseOptions(String[] operationArguments) {
    DownOperationOptions operationOptions = new DownOperationOptions();
    OptionParser parser = new OptionParser();
    parser.allowsUnrecognizedOptions();
    OptionSpec<String> optionConflictStrategy = parser.acceptsAll(asList("C", "conflict-strategy")).withRequiredArg();
    OptionSpec<Void> optionNoApply = parser.acceptsAll(asList("A", "no-apply"));
    OptionSet options = parser.parse(operationArguments);
    // --conflict-strategy=<strategy>
    if (options.has(optionConflictStrategy)) {
        String conflictStrategyStr = options.valueOf(optionConflictStrategy).toUpperCase();
        operationOptions.setConflictStrategy(DownConflictStrategy.valueOf(conflictStrategyStr));
    }
    // --no-apply
    if (options.has(optionNoApply)) {
        operationOptions.setApplyChanges(false);
    }
    return operationOptions;
}
Also used : DownOperationOptions(org.syncany.operations.down.DownOperationOptions) OptionSet(joptsimple.OptionSet) OptionParser(joptsimple.OptionParser)

Example 2 with DownOperationOptions

use of org.syncany.operations.down.DownOperationOptions in project syncany by syncany.

the class DownCommand method execute.

@Override
public int execute(String[] operationArgs) throws Exception {
    DownOperationOptions operationOptions = parseOptions(operationArgs);
    DownOperationResult operationResult = new DownOperation(config, operationOptions).execute();
    printResults(operationResult);
    return 0;
}
Also used : DownOperationResult(org.syncany.operations.down.DownOperationResult) DownOperation(org.syncany.operations.down.DownOperation) DownOperationOptions(org.syncany.operations.down.DownOperationOptions)

Aggregations

DownOperationOptions (org.syncany.operations.down.DownOperationOptions)2 OptionParser (joptsimple.OptionParser)1 OptionSet (joptsimple.OptionSet)1 DownOperation (org.syncany.operations.down.DownOperation)1 DownOperationResult (org.syncany.operations.down.DownOperationResult)1