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>, 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 {
11                apm_core::prompt::run(root, id, agent_ov, role_ov, &mut stdout)
12            }
13        }
14        (None, Some(a), Some(r)) => {
15            if explain {
16                apm_core::prompt::explain_without_ticket(root, a, r, &mut stdout)
17            } else {
18                apm_core::prompt::run_without_ticket(root, a, r, &mut stdout)
19            }
20        }
21        (None, _, _) => apm_core::prompt::discover(root, &mut stdout),
22    }
23}