Don't print welcome message when a value is piped

This commit is contained in:
bakk 2021-05-30 19:21:38 +02:00
parent 2573ae16e2
commit 2402d444f5
3 changed files with 31 additions and 5 deletions

21
Cargo.lock generated
View File

@ -18,6 +18,17 @@ dependencies = [
"winapi",
]
[[package]]
name = "atty"
version = "0.2.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
dependencies = [
"hermit-abi",
"libc",
"winapi",
]
[[package]]
name = "az"
version = "1.0.0"
@ -116,6 +127,15 @@ dependencies = [
"winapi",
]
[[package]]
name = "hermit-abi"
version = "0.1.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "322f4de77956e22ed0e5032c359a0f1273f1f7f0d79bfa3b8ffbc730d7fbcc5c"
dependencies = [
"libc",
]
[[package]]
name = "js-sys"
version = "0.3.46"
@ -142,6 +162,7 @@ name = "kalk_cli"
version = "0.5.3"
dependencies = [
"ansi_term",
"atty",
"kalk",
"lazy_static",
"regex",

View File

@ -22,6 +22,7 @@ lazy_static = "1.4.0"
regex = "1"
rustyline = "7.1.0"
seahorse = "1.1.1"
atty = "0.2.14"
[target.'cfg(windows)'.build-dependencies]
winres = "0.1"

View File

@ -24,11 +24,15 @@ pub fn start(mut parser: &mut parser::Context, precision: u32) {
highlighter: LineHighlighter {},
validator: MatchingBracketValidator::new(),
}));
// If in tty, print the welcome message
if atty::is(atty::Stream::Stdin) && atty::is(atty::Stream::Stdout) {
println!("kalk");
println!(
"{}",
ansi_term::Color::Fixed(246).paint("Type 'help' for instructions.")
);
}
loop {
let prompt = if cfg!(windows) {