kitab

Unnamed repository; edit this file 'description' to name the repository.
Info | Log | Files | Refs | LICENSE

commit 7f7f08699771a79719794add97492291ec71a4e6
parent f298f4c86c6ab89a35d6a1d4b960172f23c8f490
Author: lash <dev@holbrook.no>
Date:   Fri,  5 Aug 2022 07:06:44 +0000

Add new entry subcommand

Diffstat:
Msrc/main.rs | 39+++++++++++++++++++++++++++++++++++++++
1 file changed, 39 insertions(+), 0 deletions(-)

diff --git a/src/main.rs b/src/main.rs @@ -70,6 +70,27 @@ fn args_setup() -> ArgMatches<'static> { ); o = o.subcommand(o_apply); + let mut o_entry = ( + SubCommand::with_name("new") + .about("add metadata for file") + .version("0.0.1") + ); + o_entry = o_entry.arg(clap::Arg::with_name("validators") + .short("s") + .long("src") + .value_name("Add given validator engine") + .multiple(true) + .takes_value(true) + ); + + o_entry = o_entry.arg( + Arg::with_name("PATH") + .help("Path to operate on") + .required(true) + .index(1) + ); + o = o.subcommand(o_entry); + o.get_matches() } @@ -226,6 +247,13 @@ fn exec_import(p: &Path, index_path: &Path) { } } +fn exec_entry(p: &Path, index_path: &Path) -> bool { + if !p.is_file() { + return false; + } + true +} + fn main() { env_logger::init(); @@ -254,4 +282,15 @@ fn main() { }, _ => {}, } + + match args.subcommand_matches("new") { + Some(v) => { + let p = str_to_path(v); + info!("new metadata for path {:?}", &p); + if !exec_entry(p.as_path(), index_dir.as_path()) { + r = false; + } + }, + _ => {}, + } }