From 55361f71fe701c19057b816f89143377cfeca1f1 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 24 Nov 2015 20:07:47 +0100 Subject: [PATCH] Add struct for passing environment of command to command execute function --- src/module/command.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/module/command.rs b/src/module/command.rs index 09d2792d..9581cc85 100644 --- a/src/module/command.rs +++ b/src/module/command.rs @@ -9,10 +9,13 @@ use storage::backend::{StorageBackend, StorageBackendError}; pub type CommandError = Result; pub type CommandResult = Result<(), Result>; +pub struct CommandEnv<'a> { + pub rt: &'a Runtime<'a>, + pub matches: &'a ArgMatches<'a, 'a>, + pub backend: StorageBackend +} + pub trait ExecutableCommand { fn get_callname() -> &'static str; - fn exec(&self, - rt: &Runtime, - matches: &ArgMatches<'a, 'a>, - s: StorageBackend) -> CommandResult; + fn exec(&self, env: CommandEnv) -> CommandResult; }