use of org.syncany.operations.update.UpdateOperationAction 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;
}
Aggregations