use crate::files;
use clap::{crate_name, crate_version, App, Arg};
fn build_matches() -> clap::ArgMatches<'static> {
let app = App::new(crate_name!())
.version(crate_version!())
.author("Shift <me@shift-d.tk>")
.about("")
.arg(
Arg::with_name("init")
.help("Init important files")
.long("init"),
)
.subcommand(
App::new("create")
.about("Create new password")
.arg(
Arg::with_name("NAME")
.help("Password's name")
.required(true),
)
.arg(
Arg::with_name("category")
.help("Password's category")
.required(false)
.short("c")
.long("category")
.takes_value(true),
),
);
app.get_matches()
}
pub fn matches_interaction() {
let matches = build_matches();
if let Some(create_subcommand) = matches.subcommand_matches("create") {
if let Some(name_value) = create_subcommand.value_of("NAME") {
let content = files::edit::FileContent::default();
let password_name = name_value.to_string();
let category_name = create_subcommand.value_of("category");
content.save_passwords(category_name, password_name);
}
} else if matches.is_present("init") {
files::FilePaths::init();
files::edit::FileContent::default().init_config();
}
}