]>
Commit | Line | Data |
---|---|---|
1a4d82fc JJ |
1 | // Copyright 2014 The Rust Project Developers. See the COPYRIGHT |
2 | // file at the top-level directory of this distribution and at | |
3 | // http://rust-lang.org/COPYRIGHT. | |
4 | // | |
5 | // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | |
6 | // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | |
7 | // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | |
8 | // option. This file may not be copied, modified, or distributed | |
9 | // except according to those terms. | |
10 | ||
11 | //! An abstraction of the terminal. Eventually, provide color and | |
12 | //! verbosity support. For now, just a wrapper around stdout/stderr. | |
13 | ||
c34b1796 AL |
14 | use std::io; |
15 | use std::io::prelude::*; | |
62682a34 | 16 | use std::sync::atomic::Ordering; |
1a4d82fc JJ |
17 | |
18 | pub struct Term { | |
c34b1796 | 19 | err: Box<Write + 'static> |
1a4d82fc JJ |
20 | } |
21 | ||
22 | impl Term { | |
23 | pub fn new() -> Term { | |
24 | Term { | |
c34b1796 | 25 | err: Box::new(io::stderr()) |
1a4d82fc JJ |
26 | } |
27 | } | |
28 | ||
29 | pub fn err(&mut self, msg: &str) { | |
30 | // swallow any errors | |
c34b1796 | 31 | let _ = writeln!(&mut self.err, "{}", msg); |
62682a34 | 32 | ::EXIT_STATUS.store(101, Ordering::SeqCst); |
1a4d82fc JJ |
33 | } |
34 | } |