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;
    }
@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", 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", new Credentials("AWS456", null))
                .compareTo(new CommandLineUriParser(input, factory).parse("s3://AWS456@/cyberduck-test/key")));
        assertEquals(0, new Host(new FTPTLSProtocol(), "cyberduck.io", 55, "/folder", new Credentials("anonymous", null))
                .compareTo(new CommandLineUriParser(input, factory).parse("ftps://cyberduck.io:55/folder/")));
    }