Skip to content

Commit

Permalink
Replace atty with std is_terminal
Browse files Browse the repository at this point in the history
  • Loading branch information
AmrDeveloper committed Nov 3, 2024
1 parent d85bddd commit 722dd40
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 28 deletions.
25 changes: 2 additions & 23 deletions Cargo.lock

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

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ gitql-engine = { path = "./crates/gitql-engine", version = "0.29.0" }
gitql-cli = { path = "./crates/gitql-cli", version = "0.29.0" }
lineeditor = "0.4.1"
gix = { workspace = true, features = ["blob-diff", "max-performance"] }
atty = "0.2.14"

[dev-dependencies]
criterion = "0.5.1"
Expand Down
12 changes: 8 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
use std::io;
use std::io::IsTerminal;

use crate::git_schema::tables_fields_names;
use crate::git_schema::tables_fields_types;

use atty::Stream;
use git_data_provider::GitDataProvider;
use gitql_cli::arguments;
use gitql_cli::arguments::Arguments;
Expand Down Expand Up @@ -144,13 +146,15 @@ fn launch_gitql_repl(arguments: Arguments) {

let mut input = String::new();
loop {
let stdin = io::stdin();

// Render Prompt only if input is received from terminal
if atty::is(Stream::Stdin) {
print!("gql > ");
if stdin.is_terminal() {
print!("gitql > ");
}

std::io::Write::flush(&mut std::io::stdout()).expect("flush failed!");
match std::io::stdin().read_line(&mut input) {
match stdin.read_line(&mut input) {
Ok(buffer_length) => {
if buffer_length == 0 {
break;
Expand Down

0 comments on commit 722dd40

Please sign in to comment.