2015-12-05 00:14:13 +00:00
|
|
|
mod header;
|
|
|
|
mod commands;
|
|
|
|
|
|
|
|
use std::fmt::{Debug, Formatter};
|
|
|
|
use std::fmt::Result as FMTResult;
|
2015-10-25 18:56:04 +00:00
|
|
|
use std::path::Path;
|
|
|
|
use std::result::Result;
|
2015-12-05 00:14:13 +00:00
|
|
|
|
2015-10-25 18:56:04 +00:00
|
|
|
use clap::ArgMatches;
|
|
|
|
use regex::Regex;
|
|
|
|
|
2015-12-05 00:14:13 +00:00
|
|
|
use module::{CommandMap, Module, ModuleError, ModuleResult};
|
|
|
|
use runtime::Runtime;
|
|
|
|
use self::commands::*;
|
2015-11-10 16:38:02 +00:00
|
|
|
use self::header::build_header;
|
|
|
|
use storage::json::parser::JsonHeaderParser;
|
|
|
|
use storage::parser::FileHeaderParser;
|
2015-11-24 19:15:41 +00:00
|
|
|
|
2015-10-25 18:56:04 +00:00
|
|
|
pub struct BMModule {
|
|
|
|
path: Option<String>,
|
|
|
|
}
|
|
|
|
|
|
|
|
const CALLNAMES : &'static [&'static str] = &[ "bm", "bookmark" ];
|
|
|
|
|
2015-11-28 11:35:49 +00:00
|
|
|
impl BMModule {
|
2015-10-25 18:56:04 +00:00
|
|
|
|
2015-11-28 11:35:49 +00:00
|
|
|
pub fn new(rt : &Runtime) -> BMModule {
|
2015-10-25 18:56:04 +00:00
|
|
|
BMModule {
|
|
|
|
path: None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-28 11:35:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
impl Module for BMModule {
|
|
|
|
|
|
|
|
fn callnames(&self) -> &'static [&'static str] {
|
2015-10-25 18:56:04 +00:00
|
|
|
CALLNAMES
|
|
|
|
}
|
|
|
|
|
|
|
|
fn name(&self) -> &'static str{
|
2015-11-28 12:07:30 +00:00
|
|
|
"bookmark"
|
2015-10-25 18:56:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fn shutdown(&self, rt : &Runtime) -> ModuleResult {
|
|
|
|
Ok(())
|
|
|
|
}
|
2015-11-24 19:15:41 +00:00
|
|
|
|
2015-11-28 10:09:39 +00:00
|
|
|
fn get_commands(&self, rt: &Runtime) -> CommandMap {
|
|
|
|
let mut hm = CommandMap::new();
|
|
|
|
hm.insert("add", add_command);
|
|
|
|
hm.insert("list", list_command);
|
|
|
|
hm.insert("remove", remove_command);
|
|
|
|
hm
|
2015-11-24 19:15:41 +00:00
|
|
|
}
|
2015-10-25 18:56:04 +00:00
|
|
|
}
|
|
|
|
|
2015-11-30 17:33:30 +00:00
|
|
|
impl Debug for BMModule {
|
|
|
|
|
|
|
|
fn fmt(&self, fmt: &mut Formatter) -> FMTResult {
|
|
|
|
write!(fmt, "[Module][BM]");
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|