Add docs to BM module
This commit is contained in:
parent
ffcb951468
commit
be233b8aba
1 changed files with 37 additions and 1 deletions
|
@ -40,6 +40,9 @@ impl<'a> BM<'a> {
|
||||||
&self.rt
|
&self.rt
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Subcommand: add
|
||||||
|
*/
|
||||||
fn command_add(&self, matches: &ArgMatches) -> bool {
|
fn command_add(&self, matches: &ArgMatches) -> bool {
|
||||||
use std::process::exit;
|
use std::process::exit;
|
||||||
use self::header::build_header;
|
use self::header::build_header;
|
||||||
|
@ -100,6 +103,9 @@ impl<'a> BM<'a> {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Subcommand: list
|
||||||
|
*/
|
||||||
fn command_list(&self, matches: &ArgMatches) -> bool {
|
fn command_list(&self, matches: &ArgMatches) -> bool {
|
||||||
use ui::file::{FilePrinter, TablePrinter};
|
use ui::file::{FilePrinter, TablePrinter};
|
||||||
use std::ops::Deref;
|
use std::ops::Deref;
|
||||||
|
@ -124,6 +130,9 @@ impl<'a> BM<'a> {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Subcommand: remove
|
||||||
|
*/
|
||||||
fn command_remove(&self, matches: &ArgMatches) -> bool {
|
fn command_remove(&self, matches: &ArgMatches) -> bool {
|
||||||
use std::process::exit;
|
use std::process::exit;
|
||||||
|
|
||||||
|
@ -152,6 +161,9 @@ impl<'a> BM<'a> {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Subcommand: add_tags
|
||||||
|
*/
|
||||||
fn command_add_tags(&self, matches: &ArgMatches) -> bool {
|
fn command_add_tags(&self, matches: &ArgMatches) -> bool {
|
||||||
self.alter_tags_in_files(matches, |old_tags, cli_tags| {
|
self.alter_tags_in_files(matches, |old_tags, cli_tags| {
|
||||||
let mut new_tags = old_tags.clone();
|
let mut new_tags = old_tags.clone();
|
||||||
|
@ -160,6 +172,9 @@ impl<'a> BM<'a> {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Subcommand: rm_tags
|
||||||
|
*/
|
||||||
fn command_rm_tags(&self, matches: &ArgMatches) -> bool {
|
fn command_rm_tags(&self, matches: &ArgMatches) -> bool {
|
||||||
self.alter_tags_in_files(matches, |old_tags, cli_tags| {
|
self.alter_tags_in_files(matches, |old_tags, cli_tags| {
|
||||||
old_tags.clone()
|
old_tags.clone()
|
||||||
|
@ -169,12 +184,18 @@ impl<'a> BM<'a> {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Subcommand: set_tags
|
||||||
|
*/
|
||||||
fn command_set_tags(&self, matches: &ArgMatches) -> bool {
|
fn command_set_tags(&self, matches: &ArgMatches) -> bool {
|
||||||
self.alter_tags_in_files(matches, |old_tags, cli_tags| {
|
self.alter_tags_in_files(matches, |old_tags, cli_tags| {
|
||||||
cli_tags.clone()
|
cli_tags.clone()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper function to alter the tags in a file
|
||||||
|
*/
|
||||||
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>
|
||||||
{
|
{
|
||||||
|
@ -229,7 +250,10 @@ impl<'a> BM<'a> {
|
||||||
.all(|x| x)
|
.all(|x| x)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper function to get files from the store filtered by the constraints passed via the
|
||||||
|
* CLI
|
||||||
|
*/
|
||||||
fn get_files(&self,
|
fn get_files(&self,
|
||||||
matches: &ArgMatches,
|
matches: &ArgMatches,
|
||||||
id_key: &'static str,
|
id_key: &'static str,
|
||||||
|
@ -257,6 +281,9 @@ impl<'a> BM<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get files from the store, filtere by ID
|
||||||
|
*/
|
||||||
fn get_files_by_id(&self, hash: FileHash) -> Vec<Rc<RefCell<File>>> {
|
fn get_files_by_id(&self, hash: FileHash) -> Vec<Rc<RefCell<File>>> {
|
||||||
let parser = Parser::new(JsonHeaderParser::new(None));
|
let parser = Parser::new(JsonHeaderParser::new(None));
|
||||||
self.rt
|
self.rt
|
||||||
|
@ -266,6 +293,9 @@ impl<'a> BM<'a> {
|
||||||
.unwrap_or(vec![])
|
.unwrap_or(vec![])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get files from the store, filtere by Regex
|
||||||
|
*/
|
||||||
fn get_files_by_match(&self, matcher: String) -> Vec<Rc<RefCell<File>>> {
|
fn get_files_by_match(&self, matcher: String) -> Vec<Rc<RefCell<File>>> {
|
||||||
let parser = Parser::new(JsonHeaderParser::new(None));
|
let parser = Parser::new(JsonHeaderParser::new(None));
|
||||||
let re = Regex::new(&matcher[..]).unwrap_or_else(|e| {
|
let re = Regex::new(&matcher[..]).unwrap_or_else(|e| {
|
||||||
|
@ -292,6 +322,9 @@ impl<'a> BM<'a> {
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get files from the store, filtere by tags
|
||||||
|
*/
|
||||||
fn get_files_by_tags(&self, tags: Vec<String>) -> Vec<Rc<RefCell<File>>> {
|
fn get_files_by_tags(&self, tags: Vec<String>) -> Vec<Rc<RefCell<File>>> {
|
||||||
let parser = Parser::new(JsonHeaderParser::new(None));
|
let parser = Parser::new(JsonHeaderParser::new(None));
|
||||||
self.rt
|
self.rt
|
||||||
|
@ -309,6 +342,9 @@ impl<'a> BM<'a> {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Trait implementation for BM module
|
||||||
|
*/
|
||||||
impl<'a> Module<'a> for BM<'a> {
|
impl<'a> Module<'a> for BM<'a> {
|
||||||
|
|
||||||
fn exec(&self, matches: &ArgMatches) -> bool {
|
fn exec(&self, matches: &ArgMatches) -> bool {
|
||||||
|
|
Loading…
Reference in a new issue