use crate::Claude;
use crate::command::ClaudeCommand;
use crate::error::Result;
use crate::exec::{self, CommandOutput};
#[derive(Debug, Clone, Default)]
pub struct AgentsCommand {
setting_sources: Option<String>,
}
impl AgentsCommand {
#[must_use]
pub fn new() -> Self {
Self::default()
}
#[must_use]
pub fn setting_sources(mut self, sources: impl Into<String>) -> Self {
self.setting_sources = Some(sources.into());
self
}
}
impl ClaudeCommand for AgentsCommand {
type Output = CommandOutput;
fn args(&self) -> Vec<String> {
let mut args = vec!["agents".to_string()];
if let Some(ref sources) = self.setting_sources {
args.push("--setting-sources".to_string());
args.push(sources.clone());
}
args
}
async fn execute(&self, claude: &Claude) -> Result<CommandOutput> {
exec::run_claude(claude, self.args()).await
}
}
#[cfg(test)]
mod tests {
use super::*;
use crate::command::ClaudeCommand;
#[test]
fn test_agents_default() {
let cmd = AgentsCommand::new();
assert_eq!(ClaudeCommand::args(&cmd), vec!["agents"]);
}
#[test]
fn test_agents_with_sources() {
let cmd = AgentsCommand::new().setting_sources("user,project");
assert_eq!(
ClaudeCommand::args(&cmd),
vec!["agents", "--setting-sources", "user,project"]
);
}
}