extern crate reqwest;
extern crate env_logger;

use std::env;

fn main() {
    env_logger::init().unwrap();

    let url = match env::args().nth(1) {
        Some(url) => url,
        None => {
            println!("Usage: reqwest <url>");
            return;
        }
    };

    let res = reqwest::get(&url).unwrap();

    println!("Status: {}", res.status());
    println!("Headers:\n{}", res.headers());
}

extern crate reqwest;
extern crate env_logger;

use std::env;

pub struct Opt {
    url: Option<String>,
}

impl Opt {
    pub fn new() -> Opt {
        Opt {
            url: None,
        }
    }

    pub fn url(&mut self, url: String) {
        self.url = Some(url);
    }

    pub fn is_valid(&self) -> bool {
        return self.url.is_some();
    }
}

fn main() {
    env_logger::init().unwrap();

    let mut arguments = env::args();
    if arguments.len() < 2 {
        println!("reqwest: try 'reqwest --help' for more information");
        return;
    }
    arguments.next(); // execute name

    let mut opt = Opt::new();
    while let Some(arg) = arguments.next() {
        match arg.as_str() {
            "--url" => {
                match arguments.next() {
                    Some(url) => {
                        opt.url(url);
                    },
                    None => {
                        println!("reqwest: option --url: requires parameter");
                        println!("reqwest: try 'reqwest --help' for more information");
                        return;
                    }
                }
            },
            "--help" => {
                help();
                return;
            },
            url => {
                opt.url(url.to_string());
            }
        }
    }

    if !opt.is_valid() {
        help();
        return;
    }
    
    let res = reqwest::get(&opt.url.unwrap()).unwrap();

    println!("Status: {}", res.status());
    println!("Headers:\n{}", res.headers());
}

fn help() {
    println!("Usage: reqwest [options...] <url>");
    println!("  --url <url>");
}

Add --url option as command line argument
Add --url option as command line argument
