MCPcopy Index your code
hub / github.com/ChrisFeldmeier/OpenCodeRust / format_todos_from_data

Function format_todos_from_data

crates/opencode-tool/src/todo.rs:206–243  ·  view source on GitHub ↗
(todos: &[TodoItemData])

Source from the content-addressed store, hash-verified

204}
205
206fn format_todos_from_data(todos: &[TodoItemData]) -> String {
207 if todos.is_empty() {
208 return "No todos in the list.".to_string();
209 }
210
211 let mut output = String::new();
212 output.push_str("# Todo List\n\n");
213
214 for (i, todo) in todos.iter().enumerate() {
215 let status_icon = match todo.status.as_str() {
216 "in_progress" => "🔄",
217 "completed" => "✅",
218 _ => "⬜",
219 };
220
221 let priority_str = if !todo.priority.is_empty() {
222 format!(" [{}]", todo.priority)
223 } else {
224 String::new()
225 };
226
227 output.push_str(&format!(
228 "{} todo_{}{}\n {}\n\n",
229 status_icon, i, priority_str, todo.content
230 ));
231 }
232
233 let pending = todos.iter().filter(|t| t.status == "pending").count();
234 let in_progress = todos.iter().filter(|t| t.status == "in_progress").count();
235 let completed = todos.iter().filter(|t| t.status == "completed").count();
236
237 output.push_str(&format!(
238 "Summary: {} pending, {} in progress, {} completed",
239 pending, in_progress, completed
240 ));
241
242 output
243}
244
245impl Default for TodoReadTool {
246 fn default() -> Self {

Callers 1

executeMethod · 0.85

Calls 5

newFunction · 0.85
is_emptyMethod · 0.80
countMethod · 0.80
as_strMethod · 0.45
filterMethod · 0.45

Tested by

no test coverage detected