Skip to main content

resolve_task

Function resolve_task 

Source
pub fn resolve_task(
    arg: &Option<String>,
    agent_name: &str,
    description: Option<&str>,
    stdin_is_terminal: &dyn Fn() -> bool,
) -> Result<String>
Expand description

Resolve the task string from a CLI argument.

  • Some(s) where s is an existing file path → read file contents.
  • Some(s) otherwise → use s as a literal prompt.
  • None when stdin is not a TTY → error.
  • None when stdin is a TTY → launch the user’s editor on a temp prompt file.

stdin_is_terminal is injected (a &dyn Fn() -> bool) rather than probing the real process stdin here, so the library core stays free of direct std::io::stdin() access and is fully testable. In production the binary passes &|| std::io::stdin().is_terminal().