Skip to content

Commit

Permalink
chore: replace atty with is-terminal (sigoden#156)
Browse files Browse the repository at this point in the history
  • Loading branch information
sigoden authored and rooct committed Nov 30, 2023
1 parent 3a74860 commit af434ea
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 31 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.

3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ dirs = "5.0.0"
eventsource-stream = "0.2.3"
futures-util = "0.3.26"
inquire = "0.6.2"
is-terminal = "0.4.4"
is-terminal = "0.4.9"
reedline = "0.21.0"
serde = { version = "1.0.152", features = ["derive"] }
serde_json = "1.0.93"
Expand All @@ -27,7 +27,6 @@ tokio = { version = "1.26.0", features = ["full"] }
crossbeam = "0.8.2"
crossterm = "0.26.1"
chrono = "0.4.23"
atty = "0.2.14"
unicode-width = "0.1.10"
bincode = "1.3.3"
ctrlc = "3.2.5"
Expand Down
12 changes: 6 additions & 6 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,18 +71,18 @@ fn main() -> Result<()> {
}
let no_stream = cli.no_stream;
let client = init_client(config.clone())?;
if atty::isnt(atty::Stream::Stdin) {
if stdin().is_terminal() {
match text {
Some(text) => start_directive(client.as_ref(), &config, &text, no_stream),
None => start_interactive(config),
}
} else {
let mut input = String::new();
stdin().read_to_string(&mut input)?;
if let Some(text) = text {
input = format!("{text}\n{input}");
}
start_directive(client.as_ref(), &config, &input, no_stream)
} else {
match text {
Some(text) => start_directive(client.as_ref(), &config, &text, no_stream),
None => start_interactive(config),
}
}
}

Expand Down

0 comments on commit af434ea

Please sign in to comment.