From c4aa8dd5d50e83ec1dee251d13af544096fa3e57 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 18 May 2019 01:55:59 +0200 Subject: [PATCH 1/3] Make "urls" positional argument Signed-off-by: Matthias Beyer --- bin/domain/imag-bookmark/src/ui.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/bin/domain/imag-bookmark/src/ui.rs b/bin/domain/imag-bookmark/src/ui.rs index ed1e283c..c0828b68 100644 --- a/bin/domain/imag-bookmark/src/ui.rs +++ b/bin/domain/imag-bookmark/src/ui.rs @@ -35,14 +35,13 @@ pub fn build_ui<'a>(app: App<'a, 'a>) -> App<'a, 'a> { .value_name("COLLECTION") .help("Add to this collection, if not specified default from config will be used")) .arg(Arg::with_name("urls") - .long("urls") - .short("u") + .index(1) .takes_value(true) .required(true) .multiple(true) .value_name("URL") .validator(is_url) - .help("Add this URL, multiple possible")) + .help("Add this URL(s)")) ) .subcommand(SubCommand::with_name("remove") @@ -57,14 +56,13 @@ pub fn build_ui<'a>(app: App<'a, 'a>) -> App<'a, 'a> { .value_name("COLLECTION") .help("Remove from this collection, if not specified default from config will be used")) .arg(Arg::with_name("urls") - .long("urls") - .short("u") + .index(1) .takes_value(true) .required(true) .multiple(true) .value_name("URL") .validator(is_url) - .help("Remove these urls, regex supported")) + .help("Remove this url(s)")) ) // .subcommand(SubCommand::with_name("open") From 49c7c81ff38b13d930e660d54a8dea7777cfbbd7 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 18 May 2019 01:59:39 +0200 Subject: [PATCH 2/3] Remove unimplemented argument Signed-off-by: Matthias Beyer --- bin/domain/imag-bookmark/src/ui.rs | 8 -------- 1 file changed, 8 deletions(-) diff --git a/bin/domain/imag-bookmark/src/ui.rs b/bin/domain/imag-bookmark/src/ui.rs index c0828b68..93a48cdb 100644 --- a/bin/domain/imag-bookmark/src/ui.rs +++ b/bin/domain/imag-bookmark/src/ui.rs @@ -89,14 +89,6 @@ pub fn build_ui<'a>(app: App<'a, 'a>) -> App<'a, 'a> { .multiple(false) .value_name("COLLECTION") .help("Select from this collection, if not specified default from config will be used")) - .arg(Arg::with_name("tags") - .long("tags") - .short("t") - .takes_value(true) - .required(false) - .multiple(true) - .value_name("TAGS") - .help("Filter links to contain these tags. When multiple tags are specified, all of them must be set for the link to match.")) ) .subcommand(SubCommand::with_name("collection") From 5fa6b07b9e528ba63077977e5ce1b22b6972ed0b Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 18 May 2019 02:10:56 +0200 Subject: [PATCH 3/3] Fix: Delete links to bookmark collection entry before deleting collection Signed-off-by: Matthias Beyer --- bin/domain/imag-bookmark/Cargo.toml | 1 + bin/domain/imag-bookmark/src/main.rs | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/bin/domain/imag-bookmark/Cargo.toml b/bin/domain/imag-bookmark/Cargo.toml index 0e07d389..bd03a8e5 100644 --- a/bin/domain/imag-bookmark/Cargo.toml +++ b/bin/domain/imag-bookmark/Cargo.toml @@ -30,6 +30,7 @@ failure = "0.1" libimagrt = { version = "0.10.0", path = "../../../lib/core/libimagrt" } libimagerror = { version = "0.10.0", path = "../../../lib/core/libimagerror" } libimagbookmark = { version = "0.10.0", path = "../../../lib/domain/libimagbookmark" } +libimagentrylink = { version = "0.10.0", path = "../../../lib/entry/libimagentrylink" } libimagutil = { version = "0.10.0", path = "../../../lib/etc/libimagutil" } [dependencies.clap] diff --git a/bin/domain/imag-bookmark/src/main.rs b/bin/domain/imag-bookmark/src/main.rs index 90a98979..b2eaa795 100644 --- a/bin/domain/imag-bookmark/src/main.rs +++ b/bin/domain/imag-bookmark/src/main.rs @@ -44,6 +44,7 @@ extern crate libimagbookmark; #[macro_use] extern crate libimagrt; extern crate libimagerror; extern crate libimagutil; +extern crate libimagentrylink; use std::io::Write; use std::process::exit; @@ -60,6 +61,8 @@ use libimagerror::trace::{MapErrTrace, trace_error}; use libimagerror::io::ToExitCode; use libimagerror::exit::ExitUnwrap; use libimagutil::debug_result::DebugResult; +use libimagentrylink::internal::InternalLinker; + mod ui; @@ -130,6 +133,16 @@ fn collection(rt: &Runtime) { if scmd.is_present("remove") { // remove a collection let name = scmd.value_of("remove").unwrap(); + + { // remove all links + let _ = BookmarkCollectionStore::get(rt.store(), &name) + .map_err_trace_exit_unwrap() + .ok_or_else(|| format_err!("Collection does not exist: {}", name)) + .map_err_trace_exit_unwrap() + .unlink(rt.store()) + .map_err_trace_exit_unwrap(); + } + if let Ok(_) = BookmarkCollectionStore::delete(rt.store(), &name) { info!("Deleted: {}", name); } else {