Skip to content

Commit

Permalink
fix: Detect tty for prqlc prompt (#3240)
Browse files Browse the repository at this point in the history
  • Loading branch information
max-sixty authored Aug 3, 2023
1 parent 0d2af05 commit 74097d3
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 18 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

**Fixes**:

- `prolc` no longer displays a prompt when piping a query into its stdin
(@max-sixty, #3248).

**Documentation**:

**Web**:
Expand Down
49 changes: 34 additions & 15 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions crates/prqlc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ metadata.msrv = "1.65.0"
anstream = {version = "0.3.2", features = ["auto"]}
anyhow = {version = "1.0.57"}
ariadne = "0.3.0"
# Remove when https://github.com/PRQL/prql/issues/3228 is resolved.
atty = "0.2.14"
clap = {version = "4.3.0", features = ["derive", "env", "wrap_help"]}
clap_complete_command = "0.5.1"
clio = {version = "0.3.3", features = ['clap-parse']}
Expand All @@ -22,8 +24,8 @@ colorchoice-clap = "1.0.0"
env_logger = {version = "0.10.0", features = ["color"]}
itertools = "0.11.0"
notify = "^6.0.0"
prql-ast = {path = '../prql-ast', version = "0.9.4" }
prql-compiler = {path = '../prql-compiler', features = ["serde_yaml"], version = "0.9.4" }
prql-ast = {path = '../prql-ast', version = "0.9.4"}
prql-compiler = {path = '../prql-compiler', features = ["serde_yaml"], version = "0.9.4"}
regex = {version = "1.9.0", features = ["std", "unicode"]}
serde = "^1"
serde_json = "1.0.81"
Expand Down
7 changes: 6 additions & 1 deletion crates/prqlc/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use std::env;
use std::io::Read;
use std::io::Write;
use std::ops::Range;
use std::path::Path;
use std::path::PathBuf;
use std::process::exit;
use std::str::FromStr;
Expand Down Expand Up @@ -417,7 +418,11 @@ impl Command {
// Don't wait without a prompt when running `prqlc compile` —
// it's confusing whether it's waiting for input or not. This
// offers the prompt.
if input.is_tty() {
//
// See https://github.com/PRQL/prql/issues/3228 for details on us not
// yet using `input.is_tty()`.
// if input.is_tty() {
if input.path() == Path::new("-") && atty::is(atty::Stream::Stdin) {
#[cfg(unix)]
eprintln!("Enter PRQL, then press ctrl-d to compile:\n");
#[cfg(windows)]
Expand Down

0 comments on commit 74097d3

Please sign in to comment.