codetether_agent/cli/
run.rs1use super::RunArgs;
4use crate::session::Session;
5use anyhow::Result;
6
7pub async fn execute(args: RunArgs) -> Result<()> {
8 let message = args.message.trim();
9
10 if message.is_empty() {
11 anyhow::bail!("You must provide a message");
12 }
13
14 tracing::info!("Running with message: {}", message);
15
16 let mut session = if let Some(session_id) = args.session {
18 Session::load(&session_id).await?
19 } else if args.continue_session {
20 Session::last().await?
21 } else {
22 Session::new().await?
23 };
24
25 if let Some(model) = args.model {
27 tracing::info!("Using specified model: {}", model);
28 session.metadata.model = Some(model);
29 }
30
31 let result = session.prompt(message).await?;
33
34 match args.format.as_str() {
36 "json" => {
37 println!("{}", serde_json::to_string_pretty(&result)?);
38 }
39 _ => {
40 println!("{}", result.text);
41 }
42 }
43
44 Ok(())
45}