public static CurlOption parse(String cmdLine) {
        List<String> args = ShellWords.parse(cmdLine);

        URI url = null;
        HttpMethod method = HttpMethod.PUT;
        List<Entry<String, String>> headers = new ArrayList<>();
        Proxy proxy = NO_PROXY;

        while (!args.isEmpty()) {
            String arg = args.remove(0);
            if (arg.equals("-X")) {
                String methodArg = removeArgFor(arg, args);
                method = HttpMethod.parse(methodArg);
            } else if (arg.equals("-H")) {
                String headerArg = removeArgFor(arg, args);
                SimpleEntry<String, String> e = parseHeader(headerArg);
                headers.add(e);
            } else if (arg.equals("-x")) {
                String proxyArg = removeArgFor(arg, args);
                proxy = parseProxy(proxyArg);
            } else {
                if (url != null) {
                    throw new IllegalArgumentException("'" + cmdLine + "' was not a valid curl command");
                }
                url = parseUrl(arg);
            }
        }

        if (url == null) {
            throw new IllegalArgumentException("'" + cmdLine + "' was not a valid curl command");
        }
        return new CurlOption(proxy, method, url, headers);
    }
@Test
    public void must_provide_valid_proxy_port() {
        String uri = "https://example.com -x https://proxy.example.com";
        IllegalArgumentException exception = assertThrows(IllegalArgumentException.class, () -> CurlOption.parse(uri));
        assertThat(exception.getMessage(), is("'https://proxy.example.com' did not have a valid proxy port"));
    }