cloak 0.1.0

A Command Line OTP Authenticator application.
use clap::{App, Arg, ArgMatches, SubCommand};
use fs;
use open;

// Create arguments for `recovery_codes` subcommand
pub fn subcommand<'a, 'b>() -> App<'a, 'b> {
    SubCommand::with_name("recovery_codes")
        .about("View recovery codes for an account")
        .arg(
            Arg::with_name("account")
                .required(true)
                .help("Name of the account"),
        )
}

// Implementation for the `recovery_codes` subcommand
pub fn run(args: &ArgMatches) {
    let account_name = args.value_of("account").unwrap();
    match fs::recovery_codes(account_name) {
        Ok(file_path) => {
            match open::that(file_path) {
                Ok(_) => {}
                Err(err) => eprintln!("{}", err),
            };
        }
        Err(err) => eprintln!("{}", err),
    };
}