diff options
-rw-r--r-- | Cargo.toml | 1 | ||||
-rw-r--r-- | src/format.rs | 2 | ||||
-rw-r--r-- | src/lib.rs | 7 |
3 files changed, 6 insertions, 4 deletions
@@ -22,3 +22,4 @@ name = "prettytable" unicode-width = "^0.1"
term = "^0.4"
lazy_static = "^0.1"
+atty = "^0.1"
diff --git a/src/format.rs b/src/format.rs index c4b874e..c9546b7 100644 --- a/src/format.rs +++ b/src/format.rs @@ -197,7 +197,7 @@ impl Default for TableFormat { }
}
-/// A builder to create a `Table Format`
+/// A builder to create a `TableFormat`
pub struct FormatBuilder {
format: Box<TableFormat>
}
@@ -1,6 +1,7 @@ //! A formatted and aligned table printer written in rust
extern crate unicode_width;
extern crate term;
+extern crate atty;
#[macro_use] extern crate lazy_static;
use std::io;
@@ -147,9 +148,9 @@ impl <'a> TableSlice<'a> { /// # Panic
/// Panic if writing to standard output fails
pub fn printstd(&self) {
- let r = match stdout() {
- Some(mut o) => self.print_term(&mut *o),
- None => self.print(&mut io::stdout()),
+ let r = match (stdout(), atty::is()) {
+ (Some(mut o), true) => self.print_term(&mut *o),
+ _ => self.print(&mut io::stdout()),
};
if let Err(e) = r {
panic!("Cannot print table to standard output : {}", e);
|