diff --git a/src/module/bm/commands.rs b/src/module/bm/commands.rs index 60318061..af922fbe 100644 --- a/src/module/bm/commands.rs +++ b/src/module/bm/commands.rs @@ -1,15 +1,18 @@ use runtime::Runtime; use storage::backend::StorageBackend; -pub fn add_command(rt: &Runtime, backend: &StorageBackend) { +use module::CommandResult; +use module::CommandEnv; + +pub fn add_command(env: CommandEnv) -> CommandResult { unimplemented!() } -pub fn list_command(rt: &Runtime, backend: &StorageBackend) { +pub fn list_command(env: CommandEnv) -> CommandResult { unimplemented!() } -pub fn remove_command(rt: &Runtime, backend: &StorageBackend) { +pub fn remove_command(env: CommandEnv) -> CommandResult { unimplemented!() } diff --git a/src/module/mod.rs b/src/module/mod.rs index 33b1f8d0..7ad0ea48 100644 --- a/src/module/mod.rs +++ b/src/module/mod.rs @@ -6,6 +6,8 @@ use std::fmt::Display; use std::result::Result; use std::collections::HashMap; +use clap::{App, ArgMatches}; + use storage::backend::{StorageBackend, StorageBackendError}; pub mod bm; @@ -41,8 +43,15 @@ impl Display for ModuleError { } } +pub struct CommandEnv<'a> { + pub rt: &'a Runtime<'a>, + pub bk: &'a StorageBackend, + pub matches: &'a ArgMatches<'a, 'a>, +} + pub type ModuleResult = Result<(), ModuleError>; -pub type CommandMap<'a> = HashMap<&'a str, fn(&Runtime, &StorageBackend)>; +pub type CommandResult = ModuleResult; +pub type CommandMap<'a> = HashMap<&'a str, fn(CommandEnv) -> CommandResult>; pub trait Module {