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 testCustomProvider() throws Exception {
        final CommandLineParser parser = new PosixParser();
        final CommandLine input = parser.parse(new Options(), new String[]{});
        final SwiftProtocol protocol = new SwiftProtocol();
        final ProtocolFactory factory = new ProtocolFactory(new LinkedHashSet<>(Collections.singletonList(protocol)));
        final Profile rackspace = new ProfilePlistReader(factory).read(this.getClass().getResourceAsStream("/Rackspace US.cyberduckprofile"));
        assertSame(protocol, rackspace.getProtocol());
        factory.register(rackspace);
        final Profile generic = new ProfilePlistReader(factory).read(this.getClass().getResourceAsStream("/Openstack Swift (Keystone 2).cyberduckprofile"));
        assertSame(protocol, generic.getProtocol());
        factory.register(generic);
        assertSame(rackspace, factory.forName("swift", "rackspace"));
        assertSame(generic, factory.forName("swift", "openstack-keystone2"));

        assertEquals(rackspace, new CommandLineUriParser(input, factory).parse("rackspace://container//").getProtocol());
        assertEquals(0, new Host(rackspace, "identity.api.rackspacecloud.com", 443, "/container")
            .compareTo(new CommandLineUriParser(input, factory).parse("rackspace://container/")));

        assertEquals(generic, new CommandLineUriParser(input, factory).parse("openstack-keystone2://auth.cloud.ovh.net/container/").getProtocol());
        assertEquals(0, new Host(generic, "auth.cloud.ovh.net", 443, "/container")
            .compareTo(new CommandLineUriParser(input, factory).parse("openstack-keystone2://auth.cloud.ovh.net/container/")));
    }