From 95742615ef31e7751663b0192a882fb7e5a9d718 Mon Sep 17 00:00:00 2001 From: "Jakob L. Kreuze" Date: Sun, 14 Jun 2020 18:56:22 -0400 Subject: Don't expose image IDs through the CLI interface. --- src/birka-cli.rs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'src/birka-cli.rs') diff --git a/src/birka-cli.rs b/src/birka-cli.rs index 703da7d..1e05712 100644 --- a/src/birka-cli.rs +++ b/src/birka-cli.rs @@ -51,30 +51,30 @@ fn main() { std::process::exit(1); } let path = Path::new(&args[2]).canonicalize().unwrap(); - let id = tb.add_file(&path, &args[3..].to_vec()).unwrap(); + tb.add_file(&path, &args[3..].to_vec()).unwrap(); } "add_tags" => { if args.len() < 3 { - eprintln!("usage: {} add_tags ID [TAGS ...]", args[0]); + eprintln!("usage: {} add_tags PATH [TAGS ...]", args[0]); std::process::exit(1); } - let id = args[2].parse::().unwrap(); - tb.tag_file(id, &args[3..].to_vec()).unwrap(); + let file = tb.file_by_path(&args[2]).unwrap(); + tb.tag_file(file.id, &args[3..].to_vec()).unwrap(); } "remove_tags" => { if args.len() < 3 { - eprintln!("usage: {} remove_tags ID [TAGS ...]", args[0]); + eprintln!("usage: {} remove_tags PATH [TAGS ...]", args[0]); std::process::exit(1); } - let id = args[2].parse::().unwrap(); - tb.untag_file(id, &args[3..].to_vec()).unwrap(); + let file = tb.file_by_path(&args[2]).unwrap(); + tb.untag_file(file.id, &args[3..].to_vec()).unwrap(); } "query" => { - if args.len() < 3 { - eprintln!("usage: {} query QUERY_STRING", args[0]); - std::process::exit(1); - } - let query = database::parse_query(&args[2]).unwrap(); + let query = if args.len() < 3 { + database::parse_query("").unwrap() + } else { + database::parse_query(&args[2]).unwrap() + }; for file in tb.query(&query, None).unwrap() { println!("{}", file.path); } -- cgit v1.3