MCPcopy Create free account
hub / github.com/aws/amazon-q-developer-cli / invoke

Method invoke

crates/chat-cli/src/cli/chat/tools/todo.rs:223–381  ·  view source on GitHub ↗
(&self, os: &Os, output: &mut impl Write)

Source from the content-addressed store, hash-verified

221 }
222
223 pub async fn invoke(&self, os: &Os, output: &mut impl Write) -> Result<InvokeOutput> {
224 if !Self::is_enabled(os) {
225 queue!(
226 output,
227 StyledText::error_fg(),
228 style::Print("Todo lists are disabled. Enable them with: q settings chat.enableTodoList true"),
229 StyledText::reset(),
230 )?;
231 return Ok(InvokeOutput {
232 output: super::OutputKind::Text("Todo lists are disabled.".to_string()),
233 });
234 }
235 if let Some(id) = self.get_id() {
236 if !os.fs.exists(id_to_path(os, &id)?) {
237 let error_string = "No todo list exists with the given ID";
238 queue!(output, style::Print(error_string.yellow()))?;
239 return Ok(InvokeOutput {
240 output: super::OutputKind::Text(error_string.to_string()),
241 });
242 }
243 }
244 let (state, id) = match self {
245 TodoList::Create {
246 tasks,
247 todo_list_description: task_description,
248 } => {
249 let new_id = generate_new_todo_id();
250 let mut todo_tasks = Vec::new();
251 for task_description in tasks {
252 todo_tasks.push(Task {
253 task_description: task_description.clone(),
254 completed: false,
255 });
256 }
257
258 // Create a new todo list with the given tasks and save state
259 let state = TodoListState {
260 tasks: todo_tasks.clone(),
261 description: task_description.clone(),
262 context: Vec::new(),
263 modified_files: Vec::new(),
264 id: new_id.clone(),
265 };
266 state.save(os, &new_id).await?;
267 state.display_list(output)?;
268 (state, new_id)
269 },
270 TodoList::Complete {
271 completed_indices,
272 context_update,
273 modified_files,
274 current_id: id,
275 } => {
276 let mut state = TodoListState::load(os, id).await?;
277
278 for i in completed_indices.iter() {
279 state.tasks[*i].completed = true;
280 }

Callers

nothing calls this directly

Calls 15

id_to_pathFunction · 0.85
generate_new_todo_idFunction · 0.85
get_all_todosFunction · 0.85
to_stringMethod · 0.80
display_listMethod · 0.80
mapMethod · 0.80
insertMethod · 0.80
removeMethod · 0.80
joinMethod · 0.80
TextClass · 0.50
get_idMethod · 0.45
existsMethod · 0.45

Tested by

no test coverage detected