diff --git a/src/main.rs b/src/main.rs index ef28a5fc..1d7fabad 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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!"); } diff --git a/src/runtime.rs b/src/runtime.rs new file mode 100644 index 00000000..84ba0f2d --- /dev/null +++ b/src/runtime.rs @@ -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() + } + +}