Add runtime module
This commit is contained in:
parent
8d4a1fa45e
commit
bd6df27aec
2 changed files with 47 additions and 0 deletions
|
@ -1,11 +1,16 @@
|
|||
#[macro_use] extern crate clap;
|
||||
|
||||
use cli::Config;
|
||||
use runtime::Runtime;
|
||||
|
||||
mod cli;
|
||||
mod runtime;
|
||||
|
||||
fn main() {
|
||||
let mut config = Config::new();
|
||||
cli::configure(&mut config);
|
||||
|
||||
let rt = Runtime::new(config);
|
||||
|
||||
println!("Hello, world!");
|
||||
}
|
||||
|
|
42
src/runtime.rs
Normal file
42
src/runtime.rs
Normal file
|
@ -0,0 +1,42 @@
|
|||
use cli::Config;
|
||||
|
||||
use std::io::stderr;
|
||||
use std::io::Write;
|
||||
|
||||
pub struct Runtime {
|
||||
config : Config,
|
||||
}
|
||||
|
||||
impl Runtime {
|
||||
|
||||
pub fn new(config : Config) -> Runtime {
|
||||
Runtime {
|
||||
config: config,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn debug(&self, string : String) {
|
||||
if self.config.is_debugging() {
|
||||
println!("{}", string);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn print(&self, string : String) {
|
||||
if self.config.is_verbose() || self.config.is_debugging() {
|
||||
println!("{}", string);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn trace(string : String) {
|
||||
// writeln!(&mut stderr, "{}", string);
|
||||
}
|
||||
|
||||
pub fn is_verbose(&self) -> bool {
|
||||
self.config.is_verbose()
|
||||
}
|
||||
|
||||
pub fn is_debugging(&self) -> bool {
|
||||
self.config.is_debugging()
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue