MCPcopy Create free account
hub / github.com/ankddev/envfetch / handle_delete_mode

Function handle_delete_mode

src/interactive/controller.rs:213–233  ·  view source on GitHub ↗
(state: &mut AppState, key: KeyEvent)

Source from the content-addressed store, hash-verified

211}
212
213pub fn handle_delete_mode(state: &mut AppState, key: KeyEvent) {
214 match key.code {
215 KeyCode::Char('y') => {
216 if let Mode::Delete(ref key_name) = state.mode {
217 match variables::delete_variable(key_name.to_owned(), true) {
218 Err(err) => state.show_message(
219 &format!("Failed to delete variable: {}", err),
220 Duration::from_secs(2),
221 ),
222 Ok(_) => {
223 state.entries.retain(|(k, _)| k != key_name);
224 state.show_message("Variable deleted", Duration::from_secs(2))
225 }
226 }
227 }
228 state.mode = Mode::List;
229 }
230 KeyCode::Char('n') | KeyCode::Esc => state.mode = Mode::List,
231 _ => {}
232 }
233}
234
235#[cfg(test)]
236mod tests {

Callers 6

handle_inputFunction · 0.85
handle_input_with_eventFunction · 0.85

Calls 2

delete_variableFunction · 0.85
show_messageMethod · 0.80

Tested by 4