diff --git a/Cargo.lock b/Cargo.lock index 1ccae26..9689411 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -490,6 +490,7 @@ name = "ucg" version = "0.6.4" dependencies = [ "abortable_parser 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", "bencher 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "clap 2.26.2 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/Cargo.toml b/Cargo.toml index 19efb83..8690348 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -31,6 +31,7 @@ regex = "1" dirs = "1.0.4" unicode-segmentation = "1.2.1" rustyline = "4.1.0" +atty = "0.2" [build-dependencies] walkdir = "2.2.7" diff --git a/src/build/mod.rs b/src/build/mod.rs index f71f3c4..8836345 100644 --- a/src/build/mod.rs +++ b/src/build/mod.rs @@ -26,6 +26,8 @@ use std::rc::Rc; use rustyline; use rustyline::error::ReadlineError; +use atty; +use atty::Stream; use simple_error; use crate::ast::*; @@ -214,10 +216,12 @@ where pub fn repl(&mut self, mut editor: rustyline::Editor<()>, config_home: PathBuf) -> BuildResult { // loop - let mut lines = crate::io::StatementAccumulator::new(); - println!("Welcome to the UCG repl. Ctrl-D to exit, Ctrl-C to abort expression."); - println!("Type '#help' for help."); - println!(""); + let mut lines = crate::io::StatementAccumulator::new(); + if atty::is(Stream::Stdin) { + println!("Welcome to the UCG repl. Ctrl-D to exit, Ctrl-C to abort expression."); + println!("Type '#help' for help."); + println!(""); + } // Initialize VM with an empty OpPointer let mut vm = VM::new( self.strict,