use of org.syncany.operations.daemon.DaemonOperationOptions in project syncany by syncany.
the class DaemonCommand method execute.
@Override
public int execute(String[] operationArgs) throws Exception {
DaemonOperationOptions operationOptions = parseOptions(operationArgs);
DaemonOperationResult operationResult = new DaemonOperation(operationOptions).execute();
printResults(operationResult);
return 0;
}
use of org.syncany.operations.daemon.DaemonOperationOptions in project syncany by syncany.
the class DaemonOperationOptionsTest method testSetWatchRoots.
@Test
public void testSetWatchRoots() {
options = new DaemonOperationOptions();
List<String> watchRoots = new ArrayList<String>();
watchRoots.add("root1");
watchRoots.add("root2");
options.setWatchRoots(watchRoots);
List<String> res = options.getWatchRoots();
assertNotNull(res);
assertFalse(res.isEmpty());
assertTrue(res.contains("root1"));
assertTrue(res.contains("root2"));
}
use of org.syncany.operations.daemon.DaemonOperationOptions in project syncany by syncany.
the class DaemonOperationOptionsTest method testGetWatchRoots.
@Test
public void testGetWatchRoots() {
options = new DaemonOperationOptions();
List<String> res = options.getWatchRoots();
assertNotNull(res);
assertTrue(res.isEmpty());
}
use of org.syncany.operations.daemon.DaemonOperationOptions in project syncany by syncany.
the class DaemonCommand method parseOptions.
@Override
public DaemonOperationOptions parseOptions(String[] operationArgs) throws Exception {
DaemonOperationOptions operationOptions = new DaemonOperationOptions();
OptionParser parser = new OptionParser();
OptionSet options = parser.parse(operationArgs);
// Files
List<?> nonOptionArgs = options.nonOptionArguments();
if (nonOptionArgs.size() == 0) {
throw new Exception("Invalid syntax, no action given (start, stop, reload, restart, status, force-stop, list, add, remove).");
}
// <action>
String actionStr = nonOptionArgs.get(0).toString();
action = parseDaemonAction(actionStr);
operationOptions.setAction(action);
// add|remove (<folder-path> ...)
if (action == DaemonAction.ADD || action == DaemonAction.REMOVE) {
if (nonOptionArgs.size() < 2) {
throw new Exception("Invalid syntax, please specify a folder path.");
}
// <folder-path> ...
List<String> watchRoots = new ArrayList<>();
for (int i = 1; i < nonOptionArgs.size(); i++) {
watchRoots.add(nonOptionArgs.get(i).toString());
}
operationOptions.setWatchRoots(watchRoots);
}
return operationOptions;
}
Aggregations