Search in sources :

Example 1 with GenlinkOperationOptions

use of org.syncany.operations.init.GenlinkOperationOptions in project syncany by syncany.

the class GenlinkCommand method execute.

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

Example 2 with GenlinkOperationOptions

use of org.syncany.operations.init.GenlinkOperationOptions in project syncany by syncany.

the class GenlinkCommand method parseOptions.

@Override
public GenlinkOperationOptions parseOptions(String[] operationArgs) {
    GenlinkOperationOptions operationOptions = new GenlinkOperationOptions();
    OptionParser parser = new OptionParser();
    OptionSpec<Void> optionMachineReadable = parser.acceptsAll(asList("m", "machine-readable"));
    OptionSpec<Void> optionShort = parser.acceptsAll(asList("s", "short"));
    parser.allowsUnrecognizedOptions();
    OptionSet options = parser.parse(operationArgs);
    // --machine-readable, -m
    machineReadableOutput = options.has(optionMachineReadable);
    // --short, -s
    operationOptions.setShortUrl(options.has(optionShort));
    return operationOptions;
}
Also used : GenlinkOperationOptions(org.syncany.operations.init.GenlinkOperationOptions) OptionSet(joptsimple.OptionSet) OptionParser(joptsimple.OptionParser)

Example 3 with GenlinkOperationOptions

use of org.syncany.operations.init.GenlinkOperationOptions in project syncany by syncany.

the class InitCommand method parseOptions.

@Override
public InitOperationOptions parseOptions(String[] operationArguments) throws Exception {
    InitOperationOptions operationOptions = new InitOperationOptions();
    OptionParser parser = new OptionParser();
    OptionSpec<Void> optionNoCreateTarget = parser.acceptsAll(asList("T", "no-create-target"));
    OptionSpec<Void> optionAdvanced = parser.acceptsAll(asList("a", "advanced"));
    OptionSpec<Void> optionNoCompression = parser.acceptsAll(asList("G", "no-compression"));
    OptionSpec<Void> optionNoEncryption = parser.acceptsAll(asList("E", "no-encryption"));
    OptionSpec<String> optionPlugin = parser.acceptsAll(asList("P", "plugin")).withRequiredArg();
    OptionSpec<String> optionPluginOpts = parser.acceptsAll(asList("o", "plugin-option")).withRequiredArg();
    OptionSpec<Void> optionAddDaemon = parser.acceptsAll(asList("n", "add-daemon"));
    OptionSpec<Void> optionShortUrl = parser.acceptsAll(asList("s", "short"));
    OptionSpec<Void> optionHeadlessMode = parser.acceptsAll(asList("l", "headless"));
    OptionSpec<String> optionPassword = parser.acceptsAll(asList("password")).withRequiredArg();
    OptionSet options = parser.parse(operationArguments);
    // Set interactivity mode
    isInteractive = !options.has(optionPlugin);
    // Set headless mode
    isHeadless = options.has(optionHeadlessMode);
    // Ask or set transfer settings
    TransferSettings transferSettings = createTransferSettingsFromOptions(options, optionPlugin, optionPluginOpts);
    // Some misc settings
    boolean createTargetPath = !options.has(optionNoCreateTarget);
    boolean advancedModeEnabled = options.has(optionAdvanced);
    boolean encryptionEnabled = !options.has(optionNoEncryption);
    boolean compressionEnabled = !options.has(optionNoCompression);
    // Cipher specs: --no-encryption, --advanced
    List<CipherSpec> cipherSpecs = getCipherSpecs(encryptionEnabled, advancedModeEnabled);
    // Compression: --no-compression
    // DefaultRepoTOFactory also creates default chunkers
    RepoTOFactory repoTOFactory = new DefaultRepoTOFactory(compressionEnabled, cipherSpecs);
    // Genlink options: --short
    GenlinkOperationOptions genlinkOptions = new GenlinkOperationOptions();
    genlinkOptions.setShortUrl(options.has(optionShortUrl));
    // Set repo password
    String password = validateAndGetPassword(options, optionNoEncryption, optionPassword);
    operationOptions.setPassword(password);
    // Create configTO and repoTO
    ConfigTO configTO = createConfigTO(transferSettings);
    RepoTO repoTO = repoTOFactory.createRepoTO();
    operationOptions.setLocalDir(localDir);
    operationOptions.setConfigTO(configTO);
    operationOptions.setRepoTO(repoTO);
    operationOptions.setCreateTarget(createTargetPath);
    operationOptions.setEncryptionEnabled(encryptionEnabled);
    operationOptions.setCipherSpecs(cipherSpecs);
    operationOptions.setDaemon(options.has(optionAddDaemon));
    operationOptions.setGenlinkOptions(genlinkOptions);
    return operationOptions;
}
Also used : InitOperationOptions(org.syncany.operations.init.InitOperationOptions) DefaultRepoTOFactory(org.syncany.config.to.DefaultRepoTOFactory) TransferSettings(org.syncany.plugins.transfer.TransferSettings) GenlinkOperationOptions(org.syncany.operations.init.GenlinkOperationOptions) OptionParser(joptsimple.OptionParser) DefaultRepoTOFactory(org.syncany.config.to.DefaultRepoTOFactory) RepoTOFactory(org.syncany.config.to.RepoTOFactory) CipherSpec(org.syncany.crypto.CipherSpec) ConfigTO(org.syncany.config.to.ConfigTO) OptionSet(joptsimple.OptionSet) RepoTO(org.syncany.config.to.RepoTO)

Aggregations

GenlinkOperationOptions (org.syncany.operations.init.GenlinkOperationOptions)3 OptionParser (joptsimple.OptionParser)2 OptionSet (joptsimple.OptionSet)2 ConfigTO (org.syncany.config.to.ConfigTO)1 DefaultRepoTOFactory (org.syncany.config.to.DefaultRepoTOFactory)1 RepoTO (org.syncany.config.to.RepoTO)1 RepoTOFactory (org.syncany.config.to.RepoTOFactory)1 CipherSpec (org.syncany.crypto.CipherSpec)1 GenlinkOperation (org.syncany.operations.init.GenlinkOperation)1 GenlinkOperationResult (org.syncany.operations.init.GenlinkOperationResult)1 InitOperationOptions (org.syncany.operations.init.InitOperationOptions)1 TransferSettings (org.syncany.plugins.transfer.TransferSettings)1