2015-10-19 16:09:51 +00:00
|
|
|
pub use cli::Config;
|
2015-10-18 18:52:52 +00:00
|
|
|
|
|
|
|
use std::io::stderr;
|
|
|
|
use std::io::Write;
|
|
|
|
|
2015-10-25 18:47:17 +00:00
|
|
|
pub struct Runtime<'a> {
|
2015-10-25 19:09:49 +00:00
|
|
|
pub config : Config<'a>,
|
2015-10-18 18:52:52 +00:00
|
|
|
}
|
|
|
|
|
2015-10-25 18:47:17 +00:00
|
|
|
impl<'a> Runtime<'a> {
|
2015-10-18 18:52:52 +00:00
|
|
|
|
2015-10-25 18:47:17 +00:00
|
|
|
pub fn new(config : Config<'a>) -> Runtime<'a> {
|
2015-10-18 18:52:52 +00:00
|
|
|
Runtime {
|
|
|
|
config: config,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-10-18 19:15:05 +00:00
|
|
|
pub fn debug(&self, string : &String) {
|
2015-10-18 18:52:52 +00:00
|
|
|
if self.config.is_debugging() {
|
|
|
|
println!("{}", string);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-10-18 19:15:05 +00:00
|
|
|
pub fn print(&self, string : &String) {
|
2015-10-18 18:52:52 +00:00
|
|
|
if self.config.is_verbose() || self.config.is_debugging() {
|
|
|
|
println!("{}", string);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-10-18 19:15:05 +00:00
|
|
|
pub fn trace(string : &String) {
|
2015-10-18 18:52:52 +00:00
|
|
|
// writeln!(&mut stderr, "{}", string);
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn is_verbose(&self) -> bool {
|
|
|
|
self.config.is_verbose()
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn is_debugging(&self) -> bool {
|
|
|
|
self.config.is_debugging()
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|