Add BM::command_set_tags()
This commit is contained in:
parent
bcbd568311
commit
68f66ca27d
2 changed files with 42 additions and 0 deletions
31
etc/cli.yml
31
etc/cli.yml
|
@ -180,6 +180,37 @@ subcommands:
|
||||||
required: true
|
required: true
|
||||||
takes_value: 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:
|
- todo:
|
||||||
about: Todo module
|
about: Todo module
|
||||||
version: 0.1
|
version: 0.1
|
||||||
|
|
|
@ -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
|
fn alter_tags_in_files<F>(&self, matches: &ArgMatches, generate_new_tags: F) -> bool
|
||||||
where F: Fn(Vec<String>, &Vec<String>) -> Vec<String>
|
where F: Fn(Vec<String>, &Vec<String>) -> Vec<String>
|
||||||
{
|
{
|
||||||
|
@ -223,6 +229,7 @@ impl<'a> BM<'a> {
|
||||||
.all(|x| x)
|
.all(|x| x)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fn get_files(&self,
|
fn get_files(&self,
|
||||||
matches: &ArgMatches,
|
matches: &ArgMatches,
|
||||||
id_key: &'static str,
|
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())
|
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 => {
|
Some(_) | None => {
|
||||||
info!("No command given, doing nothing");
|
info!("No command given, doing nothing");
|
||||||
false
|
false
|
||||||
|
|
Loading…
Reference in a new issue