Add BM::command_set_tags()

This commit is contained in:
Matthias Beyer 2015-12-28 20:51:32 +01:00
parent bcbd568311
commit 68f66ca27d
2 changed files with 42 additions and 0 deletions

View file

@ -180,6 +180,37 @@ subcommands:
required: true
takes_value: true
- set_tags:
about: Set tags in bookmark(s)
version: 0.1
author: Matthias Beyer <mail@beyermatthias.de>
args:
- to_id:
long: to-id
help: Set tags in bookmark with this id
required: false
takes_value: true
- to_match:
short: m
long: to-match
help: Set tags in bookmark(s) which match this regex
required: false
takes_value: true
- to_tags:
long: to-tags
help: Set tags in bookmark(s) which have these tag(s)
required: false
takes_value: true
- tags:
short: t
long: tags
help: Set these tags
required: true
takes_value: true
- todo:
about: Todo module
version: 0.1

View file

@ -169,6 +169,12 @@ impl<'a> BM<'a> {
})
}
fn command_set_tags(&self, matches: &ArgMatches) -> bool {
self.alter_tags_in_files(matches, |old_tags, cli_tags| {
cli_tags.clone()
})
}
fn alter_tags_in_files<F>(&self, matches: &ArgMatches, generate_new_tags: F) -> bool
where F: Fn(Vec<String>, &Vec<String>) -> Vec<String>
{
@ -223,6 +229,7 @@ impl<'a> BM<'a> {
.all(|x| x)
}
fn get_files(&self,
matches: &ArgMatches,
id_key: &'static str,
@ -326,6 +333,10 @@ impl<'a> Module<'a> for BM<'a> {
self.command_rm_tags(matches.subcommand_matches("rm_tags").unwrap())
},
Some("set_tags") => {
self.command_set_tags(matches.subcommand_matches("set_tags").unwrap())
},
Some(_) | None => {
info!("No command given, doing nothing");
false