| 108 | } |
| 109 | |
| 110 | async fn execute_operation(&self, os: &Os, session: &mut ChatSession) -> OperationResult { |
| 111 | match self { |
| 112 | KnowledgeSubcommand::Show => { |
| 113 | match Self::handle_show(os, session).await { |
| 114 | Ok(_) => OperationResult::Info("".to_string()), // Empty Info, formatting already done |
| 115 | Err(e) => OperationResult::Error(format!("Failed to show knowledge base entries: {}", e)), |
| 116 | } |
| 117 | }, |
| 118 | KnowledgeSubcommand::Add { |
| 119 | name, |
| 120 | path, |
| 121 | include, |
| 122 | exclude, |
| 123 | index_type, |
| 124 | } => Self::handle_add(os, session, name, path, include, exclude, index_type).await, |
| 125 | KnowledgeSubcommand::Remove { path } => Self::handle_remove(os, session, path).await, |
| 126 | KnowledgeSubcommand::Update { path } => Self::handle_update(os, session, path).await, |
| 127 | KnowledgeSubcommand::Clear => Self::handle_clear(os, session).await, |
| 128 | KnowledgeSubcommand::Cancel { operation_id } => { |
| 129 | Self::handle_cancel(os, session, operation_id.as_deref()).await |
| 130 | }, |
| 131 | } |
| 132 | } |
| 133 | |
| 134 | async fn handle_show(os: &Os, session: &mut ChatSession) -> Result<(), std::io::Error> { |
| 135 | let agent_name = Self::get_agent(session).map(|a| a.name.clone()); |