Skip to main content

apm/cmd/
prompt.rs

1use anyhow::Result;
2use std::path::Path;
3
4pub fn run(root: &Path, id: Option<&str>, agent: Option<String>, role: Option<String>, system: bool, message: bool, explain: bool) -> Result<()> {
5    let mut stdout = std::io::stdout();
6    match (id, agent.as_deref(), role.as_deref()) {
7        (Some(id), agent_ov, role_ov) => {
8            if explain {
9                apm_core::prompt::explain(root, id, agent_ov, role_ov, &mut stdout)
10            } else if system {
11                apm_core::prompt::run(root, id, agent_ov, role_ov, &mut stdout)
12            } else if message {
13                apm_core::prompt::run_message(root, id, agent_ov, role_ov, &mut stdout)
14            } else {
15                apm_core::prompt::run_full(root, id, agent_ov, role_ov, &mut stdout)
16            }
17        }
18        (None, Some(a), Some(r)) => {
19            if explain {
20                apm_core::prompt::explain_without_ticket(root, a, r, &mut stdout)
21            } else {
22                apm_core::prompt::run_without_ticket(root, a, r, &mut stdout)
23            }
24        }
25        (None, _, _) => apm_core::prompt::discover(root, &mut stdout),
26    }
27}