mod detect;
mod setup;
use tuitbot_core::config::Config;
use tuitbot_mcp::Profile;
use crate::output::write_stdout;
pub async fn execute_serve(profile_str: &str) -> anyhow::Result<()> {
let profile: Profile = profile_str
.parse()
.map_err(|e: String| anyhow::anyhow!(e))?;
let config = Config::load(None).map_err(|e| {
anyhow::anyhow!(
"Failed to load configuration: {e}\n\
Hint: Run 'tuitbot mcp setup' or set TUITBOT_X_API__CLIENT_ID as an env var."
)
})?;
tuitbot_mcp::run_server(config, profile).await
}
pub fn print_manifest(profile_str: &str) -> anyhow::Result<()> {
let profile: Profile = profile_str
.parse()
.map_err(|e: String| anyhow::anyhow!(e))?;
let manifest = tuitbot_mcp::generate_profile_manifest(profile);
let json = serde_json::to_string_pretty(&manifest)
.map_err(|e| anyhow::anyhow!("Failed to serialize manifest: {e}"))?;
write_stdout(&json)
}
pub async fn execute_setup(out: crate::output::CliOutput) -> anyhow::Result<()> {
setup::run_setup(out).await
}