claude_wrapper/command/
agents.rs1use crate::Claude;
2use crate::command::ClaudeCommand;
3use crate::error::Result;
4use crate::exec::{self, CommandOutput};
5
6#[derive(Debug, Clone, Default)]
24pub struct AgentsCommand {
25 setting_sources: Option<String>,
26}
27
28impl AgentsCommand {
29 #[must_use]
30 pub fn new() -> Self {
31 Self::default()
32 }
33
34 #[must_use]
36 pub fn setting_sources(mut self, sources: impl Into<String>) -> Self {
37 self.setting_sources = Some(sources.into());
38 self
39 }
40}
41
42impl ClaudeCommand for AgentsCommand {
43 type Output = CommandOutput;
44
45 fn args(&self) -> Vec<String> {
46 let mut args = vec!["agents".to_string()];
47 if let Some(ref sources) = self.setting_sources {
48 args.push("--setting-sources".to_string());
49 args.push(sources.clone());
50 }
51 args
52 }
53
54 async fn execute(&self, claude: &Claude) -> Result<CommandOutput> {
55 exec::run_claude(claude, self.args()).await
56 }
57}
58
59#[cfg(test)]
60mod tests {
61 use super::*;
62 use crate::command::ClaudeCommand;
63
64 #[test]
65 fn test_agents_default() {
66 let cmd = AgentsCommand::new();
67 assert_eq!(ClaudeCommand::args(&cmd), vec!["agents"]);
68 }
69
70 #[test]
71 fn test_agents_with_sources() {
72 let cmd = AgentsCommand::new().setting_sources("user,project");
73 assert_eq!(
74 ClaudeCommand::args(&cmd),
75 vec!["agents", "--setting-sources", "user,project"]
76 );
77 }
78}