Skip to content

Commit 714474a

Browse files
author
kiran-garre
committed
feat: Add /todos show
Updates: - `/todos show` displays the current todo list - Note: This is different from the previous /todos show
1 parent 216ce00 commit 714474a

File tree

1 file changed

+23
-0
lines changed
  • crates/chat-cli/src/cli/chat/cli

1 file changed

+23
-0
lines changed

crates/chat-cli/src/cli/chat/cli/todos.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ pub enum TodoSubcommand {
2929

3030
/// Delete a to-do list
3131
Delete,
32+
33+
/// Display current to-do list
34+
Show
3235
}
3336

3437
/// Used for displaying completed and in-progress todo lists
@@ -170,6 +173,26 @@ impl TodoSubcommand {
170173
},
171174
Err(_) => return Err(ChatError::Custom("Could not show to-do lists".into())),
172175
},
176+
Self::Show => {
177+
if let Some(id) = TodoState::get_current_todo_id(os).unwrap_or(None) {
178+
let state = match TodoState::load(os, &id) {
179+
Ok(s) => s,
180+
Err(_) => {
181+
return Err(ChatError::Custom("Could not load current to-do list".into()));
182+
},
183+
};
184+
match state.display_list(&mut session.stderr) {
185+
Ok(_) => execute!(session.stderr, style::Print("\n"))?,
186+
Err(_) => {
187+
return Err(ChatError::Custom("Could not display current to-do list".into()));
188+
},
189+
};
190+
} else {
191+
execute!(session.stderr, style::Print("No to-do list currently loaded\n"))?;
192+
}
193+
194+
}
195+
173196
}
174197
Ok(ChatState::PromptUser {
175198
skip_printing_tools: true,

0 commit comments

Comments
 (0)