@Test public void testParse() throws Exception { final CommandLineParser parser = new PosixParser(); final CommandLine input = parser.parse(new Options(), new String[]{}); final ProtocolFactory factory = new ProtocolFactory(new LinkedHashSet<>(Arrays.asList(new FTPTLSProtocol(), new S3Protocol()))); factory.register(new ProfilePlistReader(factory).read(this.getClass().getResourceAsStream("/FTP.cyberduckprofile"))); factory.register(new ProfilePlistReader(factory).read(this.getClass().getResourceAsStream("/FTPS.cyberduckprofile"))); factory.register(new ProfilePlistReader(factory).read(this.getClass().getResourceAsStream("/S3 (HTTPS).cyberduckprofile"))); assertEquals(0, new Host(new S3Protocol(), "s3.amazonaws.com", 443, "/cyberduck-test/key", new Credentials("AWS456", null)) .compareTo(new CommandLineUriParser(input, factory).parse("s3:AWS456@cyberduck-test/key"))); assertEquals(0, new Host(new S3Protocol(), "s3.amazonaws.com", 443, "/cyberduck-test/key", new Credentials("AWS456", null)) .compareTo(new CommandLineUriParser(input, factory).parse("s3: assertEquals(0, new Host(new FTPTLSProtocol(), "cyberduck.io", 55, "/folder", new Credentials("anonymous", null)) .compareTo(new CommandLineUriParser(input, factory).parse("ftps: }
public Host parse(final String uri) throws HostParserException { final Host host = new HostParser(factory).get(uri); if(input.hasOption(TerminalOptionsBuilder.Params.region.name())) { host.setRegion(input.getOptionValue(TerminalOptionsBuilder.Params.region.name())); } final Path directory = new CommandLinePathParser(input, factory).parse(uri); if(directory.isDirectory()) { host.setDefaultPath(directory.getAbsolute()); } else { host.setDefaultPath(directory.getParent().getAbsolute()); } if(input.hasOption(TerminalOptionsBuilder.Params.udt.name())) { host.setTransfer(Host.TransferType.udt); } if(log.isDebugEnabled()) { log.debug(String.format("Parsed %s as %s", uri, host)); } return host; }
CommandLineUriParser { public Host parse(final String uri) throws HostParserException { final Host host = new HostParser(factory).get(uri); if(input.hasOption(TerminalOptionsBuilder.Params.region.name())) { host.setRegion(input.getOptionValue(TerminalOptionsBuilder.Params.region.name())); } final Path directory = new CommandLinePathParser(input, factory).parse(uri); if(directory.isDirectory()) { host.setDefaultPath(directory.getAbsolute()); } else { host.setDefaultPath(directory.getParent().getAbsolute()); } if(input.hasOption(TerminalOptionsBuilder.Params.udt.name())) { host.setTransfer(Host.TransferType.udt); } if(log.isDebugEnabled()) { log.debug(String.format("Parsed %s as %s", uri, host)); } return host; } }
CommandLineUriParser { public Host parse(final String uri) throws HostParserException { final Host host = new HostParser(factory).get(uri); if(input.hasOption(TerminalOptionsBuilder.Params.region.name())) { host.setRegion(input.getOptionValue(TerminalOptionsBuilder.Params.region.name())); } final Path directory = new CommandLinePathParser(input, factory).parse(uri); if(directory.isDirectory()) { host.setDefaultPath(directory.getAbsolute()); } else { host.setDefaultPath(directory.getParent().getAbsolute()); } if(input.hasOption(TerminalOptionsBuilder.Params.udt.name())) { host.setTransfer(Host.TransferType.udt); } if(log.isDebugEnabled()) { log.debug(String.format("Parsed %s as %s", uri, host)); } return host; } CommandLineUriParser(final CommandLine input);  CommandLineUriParser(final CommandLine input, final ProtocolFactory factory); }
CommandLineUriParser { public Host parse(final String uri) throws HostParserException { final Host host = new HostParser(factory).get(uri); if(input.hasOption(TerminalOptionsBuilder.Params.region.name())) { host.setRegion(input.getOptionValue(TerminalOptionsBuilder.Params.region.name())); } final Path directory = new CommandLinePathParser(input, factory).parse(uri); if(directory.isDirectory()) { host.setDefaultPath(directory.getAbsolute()); } else { host.setDefaultPath(directory.getParent().getAbsolute()); } if(input.hasOption(TerminalOptionsBuilder.Params.udt.name())) { host.setTransfer(Host.TransferType.udt); } if(log.isDebugEnabled()) { log.debug(String.format("Parsed %s as %s", uri, host)); } return host; } CommandLineUriParser(final CommandLine input);  CommandLineUriParser(final CommandLine input, final ProtocolFactory factory); Host parse(final String uri); }
CommandLineUriParser { public Host parse(final String uri) throws HostParserException { final Host host = new HostParser(factory).get(uri); if(input.hasOption(TerminalOptionsBuilder.Params.region.name())) { host.setRegion(input.getOptionValue(TerminalOptionsBuilder.Params.region.name())); } final Path directory = new CommandLinePathParser(input, factory).parse(uri); if(directory.isDirectory()) { host.setDefaultPath(directory.getAbsolute()); } else { host.setDefaultPath(directory.getParent().getAbsolute()); } if(input.hasOption(TerminalOptionsBuilder.Params.udt.name())) { host.setTransfer(Host.TransferType.udt); } if(log.isDebugEnabled()) { log.debug(String.format("Parsed %s as %s", uri, host)); } return host; } CommandLineUriParser(final CommandLine input);  CommandLineUriParser(final CommandLine input, final ProtocolFactory factory); Host parse(final String uri);  }