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