Matthias Beyer
7531b5a6d7
We need the module in the subcommand for building file paths and so on. To be able to pass it, we must remove the ::new() function from the trait, so we can make the parameter a trait object. This is no object, as the module gets build non-generically from the main(), so everything is fine with this.
58 lines
1.1 KiB
Rust
58 lines
1.1 KiB
Rust
use runtime::Runtime;
|
|
use module::Module;
|
|
use module::CommandMap;
|
|
use module::ModuleResult;
|
|
use module::ModuleError;
|
|
use std::path::Path;
|
|
use std::result::Result;
|
|
use clap::ArgMatches;
|
|
use regex::Regex;
|
|
|
|
mod header;
|
|
mod commands;
|
|
|
|
use self::header::build_header;
|
|
use storage::json::parser::JsonHeaderParser;
|
|
use storage::parser::FileHeaderParser;
|
|
|
|
use self::commands::*;
|
|
|
|
pub struct BMModule {
|
|
path: Option<String>,
|
|
}
|
|
|
|
const CALLNAMES : &'static [&'static str] = &[ "bm", "bookmark" ];
|
|
|
|
impl BMModule {
|
|
|
|
pub fn new(rt : &Runtime) -> BMModule {
|
|
BMModule {
|
|
path: None
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
impl Module for BMModule {
|
|
|
|
fn callnames(&self) -> &'static [&'static str] {
|
|
CALLNAMES
|
|
}
|
|
|
|
fn name(&self) -> &'static str{
|
|
"Bookmark"
|
|
}
|
|
|
|
fn shutdown(&self, rt : &Runtime) -> ModuleResult {
|
|
Ok(())
|
|
}
|
|
|
|
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
|
|
}
|
|
}
|
|
|