claude_wrapper/command/
agents.rs1#[cfg(feature = "async")]
9use crate::Claude;
10use crate::command::ClaudeCommand;
11#[cfg(feature = "async")]
12use crate::error::Result;
13#[cfg(feature = "async")]
14use crate::exec;
15use crate::exec::CommandOutput;
16
17#[deprecated(
31 since = "0.10.0",
32 note = "`claude agents` is now an interactive TUI in Claude Code 2.1.143+ (background-session manager). \
33 For listing/reading/writing user subagents in `~/.claude/agents/`, use \
34 `claude_wrapper::artifacts::AgentsRoot`."
35)]
36#[derive(Debug, Clone, Default)]
37pub struct AgentsCommand {
38 setting_sources: Option<String>,
39}
40
41#[allow(deprecated)]
42impl AgentsCommand {
43 #[must_use]
45 pub fn new() -> Self {
46 Self::default()
47 }
48
49 #[must_use]
51 pub fn setting_sources(mut self, sources: impl Into<String>) -> Self {
52 self.setting_sources = Some(sources.into());
53 self
54 }
55}
56
57#[allow(deprecated)]
58impl ClaudeCommand for AgentsCommand {
59 type Output = CommandOutput;
60
61 fn args(&self) -> Vec<String> {
62 let mut args = vec!["agents".to_string()];
63 if let Some(ref sources) = self.setting_sources {
64 args.push("--setting-sources".to_string());
65 args.push(sources.clone());
66 }
67 args
68 }
69
70 #[cfg(feature = "async")]
71 async fn execute(&self, claude: &Claude) -> Result<CommandOutput> {
72 exec::run_claude(claude, self.args()).await
73 }
74}
75
76#[cfg(test)]
77#[allow(deprecated)]
78mod tests {
79 use super::*;
80 use crate::command::ClaudeCommand;
81
82 #[test]
83 fn test_agents_default() {
84 let cmd = AgentsCommand::new();
85 assert_eq!(ClaudeCommand::args(&cmd), vec!["agents"]);
86 }
87
88 #[test]
89 fn test_agents_with_sources() {
90 let cmd = AgentsCommand::new().setting_sources("user,project");
91 assert_eq!(
92 ClaudeCommand::args(&cmd),
93 vec!["agents", "--setting-sources", "user,project"]
94 );
95 }
96}