Skip to content

Commit

Permalink
better support for non-stdout
Browse files Browse the repository at this point in the history
  • Loading branch information
fuyufjh committed Jul 23, 2023
1 parent eda3051 commit 1d7226c
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,17 @@ impl Session {

pub fn is_interactive(&self) -> bool {
// Enter interactive mode if prompt is empty
self.options.prompt.is_empty()
self.options.prompt.is_empty() && self.is_stdout
}

pub async fn run_one_shot(&mut self) -> Result<()> {
let prompt = self.options.prompt.join(" ");
let prompt = if !self.options.prompt.is_empty() {
self.options.prompt.join(" ")
} else if !self.is_stdout {
std::io::read_to_string(std::io::stdin())?
} else {
bail!("Prompt is required")
};

if let Some(system_prompt) = &self.options.system {
self.messages.push(Message {
Expand Down

0 comments on commit 1d7226c

Please sign in to comment.