Search in sources :

Example 1 with DaemonOperationOptions

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;
}
Also used : DaemonOperation(org.syncany.operations.daemon.DaemonOperation) DaemonOperationResult(org.syncany.operations.daemon.DaemonOperationResult) DaemonOperationOptions(org.syncany.operations.daemon.DaemonOperationOptions)

Example 2 with DaemonOperationOptions

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"));
}
Also used : ArrayList(java.util.ArrayList) DaemonOperationOptions(org.syncany.operations.daemon.DaemonOperationOptions) Test(org.junit.Test)

Example 3 with DaemonOperationOptions

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());
}
Also used : DaemonOperationOptions(org.syncany.operations.daemon.DaemonOperationOptions) Test(org.junit.Test)

Example 4 with DaemonOperationOptions

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;
}
Also used : ArrayList(java.util.ArrayList) OptionSet(joptsimple.OptionSet) DaemonOperationOptions(org.syncany.operations.daemon.DaemonOperationOptions) OptionParser(joptsimple.OptionParser)

Aggregations

DaemonOperationOptions (org.syncany.operations.daemon.DaemonOperationOptions)4 ArrayList (java.util.ArrayList)2 Test (org.junit.Test)2 OptionParser (joptsimple.OptionParser)1 OptionSet (joptsimple.OptionSet)1 DaemonOperation (org.syncany.operations.daemon.DaemonOperation)1 DaemonOperationResult (org.syncany.operations.daemon.DaemonOperationResult)1