Add modules for commands of BM module

This commit is contained in:
Matthias Beyer 2015-11-24 20:15:41 +01:00
parent 55361f71fe
commit 168852714a
2 changed files with 106 additions and 0 deletions

View file

@ -0,0 +1,92 @@
mod add {
use clap::ArgMatches;
use module::command::{CommandError, CommandResult, CommandEnv, ExecutableCommand};
use runtime::Runtime;
use storage::backend::{StorageBackend, StorageBackendError};
pub struct AddCommand;
pub impl AddCommand {
fn new() -> AddCommand {
AddCommand
}
}
pub impl ExecutableCommand for AddCommand {
fn get_callname() -> &'static str {
"add"
}
fn exec<'a>(&self, env: CommandEnv<'a>) -> CommandResult
{
}
}
}
mod list {
use clap::ArgMatches;
use module::command::{CommandError, CommandResult, CommandEnv, ExecutableCommand};
use runtime::Runtime;
use storage::backend::{StorageBackend, StorageBackendError};
pub struct ListCommand;
pub impl ListCommand {
fn new() -> ListCommand {
ListCommand
}
}
pub impl ExecutableCommand for ListCommand {
fn get_callname() -> &'static str {
"list"
}
fn exec<'a>(&self, env: CommandEnv<'a>) -> CommandResult
{
}
}
}
mod remove {
use clap::ArgMatches;
use module::command::{CommandError, CommandResult, CommandEnv, ExecutableCommand};
use runtime::Runtime;
use storage::backend::{StorageBackend, StorageBackendError};
pub struct RemoveCommand;
pub impl RemoveCommand {
fn new() -> RemoveCommand {
RemoveCommand
}
}
pub impl ExecutableCommand for RemoveCommand {
fn get_callname() -> &'static str {
"remove"
}
fn exec<'a>(&self, env: CommandEnv<'a>) -> CommandResult
{
}
}
}

View file

@ -8,10 +8,16 @@ 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 module::command::ExecutableCommand;
use self::commands::add::*;
use self::commands::list::*;
use self::commands::remove::*;
pub struct BMModule {
path: Option<String>,
@ -60,6 +66,14 @@ impl Module for BMModule {
fn shutdown(&self, rt : &Runtime) -> ModuleResult {
Ok(())
}
fn get_commands<EC: ExecutableCommand>(&self, rt: &Runtime) -> Vec<EC> {
vec![
AddCommand::new(),
ListCommand::new(),
RemoveCommand::new(),
]
}
}
fn add<'a>(rt: &Runtime, sub: &ArgMatches<'a, 'a>) -> ModuleResult {