]> git.proxmox.com Git - rustc.git/blob - src/tools/rustbook/term.rs
Imported Upstream version 1.9.0+dfsg1
[rustc.git] / src / tools / rustbook / term.rs
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
14 use std::io;
15 use std::io::prelude::*;
16 use std::sync::atomic::Ordering;
17
18 pub struct Term {
19 err: Box<Write + 'static>
20 }
21
22 impl Term {
23 pub fn new() -> Term {
24 Term {
25 err: Box::new(io::stderr())
26 }
27 }
28
29 pub fn err(&mut self, msg: &str) {
30 // swallow any errors
31 let _ = writeln!(&mut self.err, "{}", msg);
32 ::EXIT_STATUS.store(101, Ordering::SeqCst);
33 }
34 }