Add CommandEnv building in command calling code in main()
This commit is contained in:
parent
0a026002b0
commit
fda2c4feea
1 changed files with 13 additions and 4 deletions
17
src/main.rs
17
src/main.rs
|
@ -13,6 +13,7 @@ use runtime::{ImagLogger, Runtime};
|
||||||
use clap::App;
|
use clap::App;
|
||||||
use module::Module;
|
use module::Module;
|
||||||
use module::ModuleError;
|
use module::ModuleError;
|
||||||
|
use module::CommandEnv;
|
||||||
use module::bm::BMModule;
|
use module::bm::BMModule;
|
||||||
use storage::backend::StorageBackend;
|
use storage::backend::StorageBackend;
|
||||||
|
|
||||||
|
@ -47,10 +48,18 @@ fn main() {
|
||||||
|
|
||||||
let backend = StorageBackend::new(rt.get_rtp());
|
let backend = StorageBackend::new(rt.get_rtp());
|
||||||
|
|
||||||
match commands.get(command) {
|
let cmdenv = CommandEnv {
|
||||||
Some(f) => f(&rt, &backend),
|
rt: &rt,
|
||||||
None => debug!("No command '{}' found", command),
|
bk: &backend,
|
||||||
}
|
matches: matches,
|
||||||
|
};
|
||||||
|
|
||||||
|
let result = match commands.get(command) {
|
||||||
|
Some(f) => f(cmdenv),
|
||||||
|
None => Err(ModuleError::new("No subcommand found")),
|
||||||
|
};
|
||||||
|
|
||||||
|
debug!("Result of command: {:?}", result);
|
||||||
} else {
|
} else {
|
||||||
debug!("No subcommand");
|
debug!("No subcommand");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue