use std;

pub enum 
 {
    Invalid,
    Help,
    Create(String, Vec<String>),
    Extract(String),
    List(String),
}

impl Arguments {
    pub fn parseargs() -> Arguments {
        enum Action { Create, Extract, List }
        let mut action = None;
        let mut archive: Option<String> = None;
        let mut files: Vec<String> = Vec::new();

        let mut args = std::env::args();
        args.next();
        while let Some(arg) = args.next() {
            match arg.as_ref() {
                "-h" => return Arguments::Help,
                "-c" => action = Some(Action::Create),
                "-x" => action = Some(Action::Extract),
                "-l" => action = Some(Action::List),
                "-f" => archive = args.next(),
                _ => files.push(arg),
            }
        }

        let archive = match archive {
            None => return Arguments::Invalid,
            Some(fname) => fname,
        };

        return match action {
            None => Arguments::Invalid,
            Some(Action::Create) => Arguments::Create(archive, files),
            Some(Action::Extract) => Arguments::Extract(archive),
            Some(Action::List) => Arguments::List(archive),
        };
    }
}

Arguments