Add modules for commands of BM module
This commit is contained in:
parent
55361f71fe
commit
168852714a
2 changed files with 106 additions and 0 deletions
92
src/module/bm/commands/mod.rs
Normal file
92
src/module/bm/commands/mod.rs
Normal 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
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -8,10 +8,16 @@ use clap::ArgMatches;
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
|
|
||||||
mod header;
|
mod header;
|
||||||
|
mod commands;
|
||||||
|
|
||||||
use self::header::build_header;
|
use self::header::build_header;
|
||||||
use storage::json::parser::JsonHeaderParser;
|
use storage::json::parser::JsonHeaderParser;
|
||||||
use storage::parser::FileHeaderParser;
|
use storage::parser::FileHeaderParser;
|
||||||
|
use module::command::ExecutableCommand;
|
||||||
|
|
||||||
|
use self::commands::add::*;
|
||||||
|
use self::commands::list::*;
|
||||||
|
use self::commands::remove::*;
|
||||||
|
|
||||||
pub struct BMModule {
|
pub struct BMModule {
|
||||||
path: Option<String>,
|
path: Option<String>,
|
||||||
|
@ -60,6 +66,14 @@ impl Module for BMModule {
|
||||||
fn shutdown(&self, rt : &Runtime) -> ModuleResult {
|
fn shutdown(&self, rt : &Runtime) -> ModuleResult {
|
||||||
Ok(())
|
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 {
|
fn add<'a>(rt: &Runtime, sub: &ArgMatches<'a, 'a>) -> ModuleResult {
|
||||||
|
|
Loading…
Reference in a new issue