Cyberduck Mountain Duck CLI

Changeset 16937


Ignore:
Timestamp:
Feb 23, 2015 1:50:21 PM (7 years ago)
Author:
dkocher
Message:

Add bandwidth throttle option.

Location:
trunk/source/ch/cyberduck/cli
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/ch/cyberduck/cli/Terminal.java

    r16902 r16937  
    199199                case upload:
    200200                case synchronize:
    201                     transfer = TerminalTransferFactory.create(action, host,
     201                    transfer = TerminalTransferFactory.create(input, host,
    202202                            new ArrayList<TransferItem>(new SingleTransferItemFinder().find(input, action, remote)));
    203203                    break;
  • trunk/source/ch/cyberduck/cli/TerminalOptionsBuilder.java

    r16678 r16937  
    134134                .isRequired(false)
    135135                .create('c'));
     136        options.addOption(OptionBuilder
     137                .withDescription("Throttle bandwidth")
     138                .withLongOpt(Params.throttle.name())
     139                .hasArg(true).withArgName("bytes per second")
     140                .isRequired(false)
     141                .create());
    136142        final StringBuilder b = new StringBuilder().append(StringUtils.LF);
    137143        final Set<TransferAction> actions = new HashSet<TransferAction>(TransferAction.forTransfer(Transfer.Type.download));
     
    186192        udt,
    187193        parallel,
     194        throttle,
    188195        existing,
    189196        verbose,
  • trunk/source/ch/cyberduck/cli/TerminalTransferFactory.java

    r16444 r16937  
    2828import ch.cyberduck.core.transfer.UploadTransfer;
    2929
     30import org.apache.commons.cli.CommandLine;
     31
    3032import java.util.List;
    3133
     
    3941    }
    4042
    41     public static Transfer create(final TerminalAction type, final Host host, final List<TransferItem> items) throws BackgroundException {
     43    public static Transfer create(final CommandLine input, final Host host, final List<TransferItem> items) throws BackgroundException {
    4244        final Transfer transfer;
     45        final TerminalAction type = TerminalActionFinder.get(input);
    4346        switch(type) {
    4447            case download:
     
    5558                        String.format("Unknown transfer type %s", type.name()));
    5659        }
     60        if(input.hasOption(TerminalOptionsBuilder.Params.throttle.name())) {
     61            try {
     62                transfer.setBandwidth(Float.valueOf(input.getOptionValue(TerminalOptionsBuilder.Params.throttle.name())));
     63            }
     64            catch(NumberFormatException ignore) {
     65                //
     66            }
     67        }
    5768        return transfer;
    5869    }
Note: See TracChangeset for help on using the changeset viewer.