command-vault 0.3.0

An advanced command history manager with tagging and search capabilities
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
use anyhow::Result;
use chrono::{TimeZone, Utc};
use command_vault::{
    db::{Command, Database},
    ui::{app::App, AddCommandApp},
};
use crate::test_utils::create_test_db;
use command_vault::ui::add::InputMode;
use ratatui::style::Color;

mod test_utils;

fn create_test_commands() -> Vec<Command> {
    vec![
        Command {
            id: Some(1),
            command: "ls -la".to_string(),
            timestamp: Utc.with_ymd_and_hms(2024, 1, 1, 0, 0, 0).unwrap(),
            directory: "/home/user".to_string(),
            tags: vec!["file".to_string(), "list".to_string()],
            parameters: vec![],
        },
        Command {
            id: Some(2),
            command: "git status".to_string(),
            timestamp: Utc.with_ymd_and_hms(2024, 1, 1, 0, 0, 1).unwrap(),
            directory: "/home/user/project".to_string(),
            tags: vec!["git".to_string()],
            parameters: vec![],
        },
        Command {
            id: Some(3),
            command: "docker ps".to_string(),
            timestamp: Utc.with_ymd_and_hms(2024, 1, 1, 0, 0, 2).unwrap(),
            directory: "/home/user".to_string(),
            tags: vec!["docker".to_string()],
            parameters: vec![],
        },
    ]
}

#[test]
fn test_app_new() -> Result<()> {
    let (mut db, _dir) = create_test_db()?;
    let commands = vec![];
    let app = App::new(commands.clone(), &mut db, false);
    assert_eq!(app.commands.len(), 0);
    assert_eq!(app.selected, None);
    assert_eq!(app.show_help, false);
    assert_eq!(app.message, None);
    assert_eq!(app.filter_text, "");
    assert_eq!(app.filtered_commands.len(), 0);
    assert_eq!(app.debug_mode, false);
    Ok(())
}

#[test]
fn test_app_filter() -> Result<()> {
    let (mut db, _dir) = create_test_db()?;
    let commands = vec![
        Command {
            id: Some(1),
            command: "ls -l".to_string(),
            timestamp: Utc::now(),
            directory: "/".to_string(),
            tags: vec![],
            parameters: vec![],
        },
        Command {
            id: Some(2),
            command: "pwd".to_string(),
            timestamp: Utc::now(),
            directory: "/".to_string(),
            tags: vec![],
            parameters: vec![],
        },
    ];
    let mut app = App::new(commands.clone(), &mut db, false);
    app.filter_text = "ls".to_string();
    app.update_filtered_commands();
    assert_eq!(app.filtered_commands.len(), 1);
    assert_eq!(app.filtered_commands[0], 0);
    Ok(())
}

#[test]
fn test_app_filtering() -> Result<()> {
    let (mut db, _dir) = create_test_db()?;
    let commands = create_test_commands();
    let mut app = App::new(commands.clone(), &mut db, false);

    // Test initial state
    assert_eq!(app.filter_text, "");
    assert_eq!(app.filtered_commands.len(), 3);

    // Test filtering by command
    app.filter_text = "git".to_string();
    app.update_filtered_commands();
    assert_eq!(app.filtered_commands.len(), 1);
    assert_eq!(app.commands[app.filtered_commands[0]].command, "git status");

    // Test filtering by tag
    app.filter_text = "file".to_string();
    app.update_filtered_commands();
    assert_eq!(app.filtered_commands.len(), 1);
    assert_eq!(app.commands[app.filtered_commands[0]].command, "ls -la");

    // Test filtering by directory
    app.filter_text = "project".to_string();
    app.update_filtered_commands();
    assert_eq!(app.filtered_commands.len(), 1);
    assert_eq!(app.commands[app.filtered_commands[0]].command, "git status");

    // Test no matches
    app.filter_text = "nonexistent".to_string();
    app.update_filtered_commands();
    assert_eq!(app.filtered_commands.len(), 0);

    Ok(())
}

#[test]
fn test_add_command_app_new() {
    let app = AddCommandApp::new();
    assert!(app.command.is_empty());
    assert!(app.tags.is_empty());
    assert!(app.current_tag.is_empty());
    assert_eq!(app.command_cursor, 0);
}

#[test]
fn test_add_command_app_command_input() {
    let mut app = AddCommandApp::new();
    app.set_command("ls -la".to_string());
    assert_eq!(app.command, "ls -la");
}

#[test]
fn test_add_command_app_tag_input() {
    let mut app = AddCommandApp::new();
    
    // Test single tag
    app.set_tags(vec!["git".to_string()]);
    assert_eq!(app.tags, vec!["git"]);
    
    // Test multiple tags
    app.set_tags(vec!["git".to_string(), "docker".to_string()]);
    assert_eq!(app.tags, vec!["git", "docker"]);
}

#[test]
fn test_app_message() -> Result<()> {
    let (mut db, _dir) = create_test_db()?;
    let mut commands = create_test_commands();
    
    // Add commands to the database first
    for cmd in &mut commands {
        cmd.id = Some(db.add_command(cmd)?);
    }
    
    let mut app = App::new(commands.clone(), &mut db, false);

    // Initial state
    assert_eq!(app.message, None);

    // Set a success message
    app.message = Some(("Command copied to clipboard!".to_string(), Color::Green));
    assert_eq!(app.message, Some(("Command copied to clipboard!".to_string(), Color::Green)));

    // Set an error message
    app.message = Some(("Failed to delete command".to_string(), Color::Red));
    assert_eq!(app.message, Some(("Failed to delete command".to_string(), Color::Red)));

    // Clear message
    app.message = None;
    assert_eq!(app.message, None);

    // Set an info message
    app.message = Some(("Type to filter commands...".to_string(), Color::Blue));
    assert_eq!(app.message, Some(("Type to filter commands...".to_string(), Color::Blue)));

    // Set a warning message
    app.message = Some(("Delete operation cancelled".to_string(), Color::Yellow));
    assert_eq!(app.message, Some(("Delete operation cancelled".to_string(), Color::Yellow)));

    Ok(())
}

#[test]
fn test_app_selection() -> Result<()> {
    let (mut db, _dir) = create_test_db()?;
    let commands = create_test_commands();
    let mut app = App::new(commands.clone(), &mut db, false);

    // Test initial state
    assert_eq!(app.selected, None);

    // Test selecting a command
    app.selected = Some(0);
    assert_eq!(app.selected, Some(0));

    // Test selecting another command
    app.selected = Some(1);
    assert_eq!(app.selected, Some(1));

    // Test selecting last command
    app.selected = Some(app.commands.len() - 1);
    assert_eq!(app.selected, Some(2));

    Ok(())
}

#[test]
fn test_app_confirm_delete() -> Result<()> {
    let (mut db, _dir) = create_test_db()?;
    let commands = create_test_commands();
    let mut app = App::new(commands.clone(), &mut db, false);

    // Test setting confirm delete
    app.selected = Some(0);
    app.confirm_delete = Some(0);
    assert_eq!(app.confirm_delete, Some(0));

    // Test canceling delete
    app.confirm_delete = None;
    assert_eq!(app.confirm_delete, None);

    Ok(())
}

#[test]
fn test_app_debug_mode() -> Result<()> {
    let (mut db, _dir) = create_test_db()?;
    let commands = create_test_commands();
    
    // Test debug mode enabled
    let mut app = App::new(commands.clone(), &mut db, true);
    assert_eq!(app.debug_mode, true);
    
    // Test debug mode disabled
    let mut app = App::new(commands.clone(), &mut db, false);
    assert_eq!(app.debug_mode, false);

    Ok(())
}

#[test]
fn test_app_help_toggle() -> Result<()> {
    let (mut db, _dir) = create_test_db()?;
    let commands = create_test_commands();
    let mut app = App::new(commands.clone(), &mut db, false);

    // Test initial state
    assert_eq!(app.show_help, false);

    // Test toggling help on
    app.show_help = true;
    assert_eq!(app.show_help, true);

    // Test toggling help off
    app.show_help = false;
    assert_eq!(app.show_help, false);

    Ok(())
}

#[test]
fn test_add_command_app_cursor_movement() {
    let mut app = AddCommandApp::new();
    
    // Test initial cursor position
    assert_eq!(app.command_cursor, 0);
    
    // Test setting cursor position
    app.set_command("ls -la".to_string());
    app.command_cursor = 3;
    assert_eq!(app.command_cursor, 3);
}

#[test]
fn test_app_filter_clear() -> Result<()> {
    let (mut db, _dir) = create_test_db()?;
    let commands = create_test_commands();
    let mut app = App::new(commands.clone(), &mut db, false);

    // Test initial state
    assert_eq!(app.filter_text, "");
    assert_eq!(app.filtered_commands.len(), 3);

    // Apply filter
    app.filter_text = "git".to_string();
    app.update_filtered_commands();
    assert_eq!(app.filtered_commands.len(), 1);
    assert_eq!(app.commands[app.filtered_commands[0]].command, "git status");

    // Clear filter
    app.filter_text.clear();
    app.update_filtered_commands();
    assert_eq!(app.filter_text, "");
    assert_eq!(app.filtered_commands.len(), 3);

    Ok(())
}

#[test]
fn test_add_command_app_tag_operations() {
    let mut app = AddCommandApp::new();
    
    // Test adding a tag
    app.current_tag = "git".to_string();
    app.tags.push(app.current_tag.clone());
    assert_eq!(app.tags, vec!["git"]);
    
    // Test clearing current tag
    app.current_tag.clear();
    assert!(app.current_tag.is_empty());
    
    // Test adding multiple tags
    app.tags.push("docker".to_string());
    app.tags.push("test".to_string());
    assert_eq!(app.tags, vec!["git", "docker", "test"]);
}

#[test]
fn test_add_command_app_input_modes() {
    use command_vault::ui::add::InputMode;
    let mut app = AddCommandApp::new();
    
    // Test initial mode
    assert!(matches!(app.input_mode, InputMode::Command));
    
    // Test switching to Tag mode
    app.input_mode = InputMode::Tag;
    assert!(matches!(app.input_mode, InputMode::Tag));
    
    // Test switching to Confirm mode
    app.input_mode = InputMode::Confirm;
    assert!(matches!(app.input_mode, InputMode::Confirm));
    
    // Test switching to Help mode
    app.input_mode = InputMode::Help;
    assert!(matches!(app.input_mode, InputMode::Help));
    
    // Test storing previous mode
    app.previous_mode = InputMode::Command;
    assert!(matches!(app.previous_mode, InputMode::Command));
}

#[test]
fn test_add_command_app_tag_suggestions() {
    let mut app = AddCommandApp::new();
    
    // Test initial state
    assert!(app.suggested_tags.is_empty());
    
    // Test adding suggested tags
    app.suggested_tags = vec!["git".to_string(), "docker".to_string()];
    assert_eq!(app.suggested_tags, vec!["git", "docker"]);
    
    // Test clearing suggestions
    app.suggested_tags.clear();
    assert!(app.suggested_tags.is_empty());
}

#[test]
fn test_add_command_app_multiline() {
    let mut app = AddCommandApp::new();
    
    // Test initial state
    assert_eq!(app.command_line, 0);
    
    // Test setting command with multiple lines
    app.set_command("line1\nline2\nline3".to_string());
    assert_eq!(app.command, "line1\nline2\nline3");
    
    // Test cursor movement across lines
    app.command_cursor = 6;  // After "line1\n"
    assert_eq!(app.command_cursor, 6);
}

#[test]
fn test_add_command_app_key_events() {
    use crossterm::event::{KeyCode, KeyEvent, KeyModifiers};

    let mut app = AddCommandApp::new();

    // Test command input
    app.handle_key_event(KeyEvent::new(KeyCode::Char('l'), KeyModifiers::empty()));
    app.handle_key_event(KeyEvent::new(KeyCode::Char('s'), KeyModifiers::empty()));
    assert_eq!(app.command, "ls");
    assert_eq!(app.command_cursor, 2);

    // Test backspace
    app.handle_key_event(KeyEvent::new(KeyCode::Backspace, KeyModifiers::empty()));
    assert_eq!(app.command, "l");
    assert_eq!(app.command_cursor, 1);

    // Test cursor movement
    app.handle_key_event(KeyEvent::new(KeyCode::Left, KeyModifiers::empty()));
    assert_eq!(app.command_cursor, 0);
    app.handle_key_event(KeyEvent::new(KeyCode::Right, KeyModifiers::empty()));
    assert_eq!(app.command_cursor, 1);

    // Test multiline command
    app.handle_key_event(KeyEvent::new(KeyCode::Enter, KeyModifiers::SHIFT));
    app.handle_key_event(KeyEvent::new(KeyCode::Char('a'), KeyModifiers::empty()));
    assert_eq!(app.command, "l\na");
    assert_eq!(app.command_line, 1);

    // Test switching to tag mode
    app.handle_key_event(KeyEvent::new(KeyCode::Enter, KeyModifiers::empty()));
    assert_eq!(app.input_mode, InputMode::Tag);

    // Test tag input
    app.handle_key_event(KeyEvent::new(KeyCode::Char('t'), KeyModifiers::empty()));
    app.handle_key_event(KeyEvent::new(KeyCode::Char('a'), KeyModifiers::empty()));
    app.handle_key_event(KeyEvent::new(KeyCode::Char('g'), KeyModifiers::empty()));
    assert_eq!(app.current_tag, "tag");

    // Test adding tag
    app.handle_key_event(KeyEvent::new(KeyCode::Enter, KeyModifiers::empty()));
    assert_eq!(app.tags, vec!["tag"]);
    assert_eq!(app.current_tag, "");

    // Test help mode
    app.handle_key_event(KeyEvent::new(KeyCode::Char('?'), KeyModifiers::empty()));
    assert_eq!(app.input_mode, InputMode::Help);
    assert_eq!(app.previous_mode, InputMode::Tag);

    // Test exiting help mode
    app.handle_key_event(KeyEvent::new(KeyCode::Char('?'), KeyModifiers::empty()));
    assert_eq!(app.input_mode, InputMode::Tag);
}

#[test]
fn test_add_command_app_help_mode() {
    use command_vault::ui::add::InputMode;
    use crossterm::event::{KeyCode, KeyEvent, KeyModifiers};
    let mut app = AddCommandApp::new();
    
    // Test entering help mode
    app.handle_key_event(KeyEvent::new(KeyCode::Char('?'), KeyModifiers::empty()));
    assert!(matches!(app.input_mode, InputMode::Help));
    assert!(matches!(app.previous_mode, InputMode::Command));
    
    // Test exiting help mode with ?
    app.handle_key_event(KeyEvent::new(KeyCode::Char('?'), KeyModifiers::empty()));
    assert!(matches!(app.input_mode, InputMode::Command));
    
    // Test exiting help mode with Esc
    app.handle_key_event(KeyEvent::new(KeyCode::Char('?'), KeyModifiers::empty()));
    assert!(matches!(app.input_mode, InputMode::Help));
    app.handle_key_event(KeyEvent::new(KeyCode::Esc, KeyModifiers::empty()));
    assert!(matches!(app.input_mode, InputMode::Command));
}

#[test]
fn test_add_command_app_multiline_command() {
    use crossterm::event::{KeyCode, KeyEvent, KeyModifiers};
    let mut app = AddCommandApp::new();
    
    // Test entering multiline command
    app.handle_key_event(KeyEvent::new(KeyCode::Char('l'), KeyModifiers::empty()));
    app.handle_key_event(KeyEvent::new(KeyCode::Char('s'), KeyModifiers::empty()));
    app.handle_key_event(KeyEvent::new(KeyCode::Enter, KeyModifiers::SHIFT));
    app.handle_key_event(KeyEvent::new(KeyCode::Char('p'), KeyModifiers::empty()));
    app.handle_key_event(KeyEvent::new(KeyCode::Char('w'), KeyModifiers::empty()));
    app.handle_key_event(KeyEvent::new(KeyCode::Char('d'), KeyModifiers::empty()));
    
    assert_eq!(app.command, "ls\npwd");
    assert_eq!(app.command_line, 1);
    assert_eq!(app.command_cursor, 6);
}

#[test]
fn test_app_command_copy() -> Result<()> {
    let (mut db, _dir) = create_test_db()?;
    let commands = create_test_commands();
    let mut app = App::new(commands.clone(), &mut db, false);

    // Select a command
    app.selected = Some(0);
    assert_eq!(app.selected, Some(0));
    assert_eq!(app.filtered_commands[0], 0);
    assert_eq!(app.commands[app.filtered_commands[0]].command, "ls -la");

    // Verify the command to be copied
    if let Some(selected) = app.selected {
        if let Some(&idx) = app.filtered_commands.get(selected) {
            if let Some(cmd) = app.commands.get(idx) {
                assert_eq!(cmd.command, "ls -la");
            }
        }
    }

    Ok(())
}

#[test]
fn test_app_navigation() -> Result<()> {
    let (mut db, _dir) = create_test_db()?;
    let commands = create_test_commands();
    let mut app = App::new(commands.clone(), &mut db, false);

    // Test initial state
    assert_eq!(app.selected, None);
    assert_eq!(app.filtered_commands.len(), 3);

    // Test moving down
    app.selected = Some(0);
    assert_eq!(app.selected, Some(0));

    // Test moving down again
    app.selected = Some(1);
    assert_eq!(app.selected, Some(1));

    // Test moving up
    app.selected = Some(0);
    assert_eq!(app.selected, Some(0));

    // Test moving up at the top (should stay at 0)
    app.selected = Some(0);
    assert_eq!(app.selected, Some(0));

    // Test moving down at the bottom (should stay at last index)
    app.selected = Some(2);
    assert_eq!(app.selected, Some(2));

    // Test selection with filtered commands
    app.filter_text = "git".to_string();
    app.update_filtered_commands();
    assert_eq!(app.filtered_commands.len(), 1);
    app.selected = Some(0);
    assert_eq!(app.selected, Some(0));

    Ok(())
}

#[test]
fn test_app_delete_command() -> Result<()> {
    let (mut db, _dir) = create_test_db()?;
    let mut commands = create_test_commands();
    
    // Add commands to the database first
    for cmd in &mut commands {
        cmd.id = Some(db.add_command(cmd)?);
    }
    
    let mut app = App::new(commands.clone(), &mut db, false);

    // Initial state
    assert_eq!(app.commands.len(), 3);
    assert_eq!(app.filtered_commands.len(), 3);
    assert_eq!(app.confirm_delete, None);

    // Select a command
    app.selected = Some(0);
    assert_eq!(app.selected, Some(0));

    // Initiate delete
    app.confirm_delete = Some(0);
    assert_eq!(app.confirm_delete, Some(0));

    // Cancel delete
    app.confirm_delete = None;
    assert_eq!(app.confirm_delete, None);
    assert_eq!(app.commands.len(), 3);

    // Initiate delete again
    app.confirm_delete = Some(0);
    assert_eq!(app.confirm_delete, Some(0));

    // Confirm delete
    if let Some(selected) = app.selected {
        if let Some(confirm_idx) = app.confirm_delete {
            if confirm_idx == selected {
                if let Some(&filtered_idx) = app.filtered_commands.get(selected) {
                    if let Some(command_id) = app.commands[filtered_idx].id {
                        match app.db.delete_command(command_id) {
                            Ok(_) => {
                                app.commands.remove(filtered_idx);
                                app.update_filtered_commands();
                                // Update selection after deletion
                                if app.filtered_commands.is_empty() {
                                    app.selected = None;
                                } else {
                                    app.selected = Some(selected.min(app.filtered_commands.len() - 1));
                                }
                            }
                            Err(e) => panic!("Failed to delete command: {}", e),
                        }
                        app.confirm_delete = None;
                    }
                }
            }
        }
    }

    // Verify deletion
    assert_eq!(app.commands.len(), 2);
    assert_eq!(app.filtered_commands.len(), 2);
    assert_eq!(app.confirm_delete, None);
    assert_eq!(app.selected, Some(0));

    Ok(())
}

#[test]
fn test_app_edit_command() -> Result<()> {
    let (mut db, _dir) = create_test_db()?;
    let mut commands = create_test_commands();
    
    // Add commands to the database first
    for cmd in &mut commands {
        cmd.id = Some(db.add_command(cmd)?);
    }
    
    let mut app = App::new(commands.clone(), &mut db, false);

    // Initial state
    assert_eq!(app.commands.len(), 3);
    assert_eq!(app.filtered_commands.len(), 3);

    // Select a command
    app.selected = Some(0);
    assert_eq!(app.selected, Some(0));

    // Get the original command
    let original_command = app.commands[0].clone();
    assert_eq!(original_command.command, "ls -la");

    // Update the command
    let updated_command = Command {
        id: original_command.id,
        command: "ls -lah".to_string(),
        timestamp: original_command.timestamp,
        directory: original_command.directory.clone(),
        tags: vec!["test".to_string(), "updated".to_string()],
        parameters: vec![],
    };

    // Update in database
    app.db.update_command(&updated_command)?;

    // Update in app's command list
    app.commands[0] = updated_command.clone();

    // Verify the update
    assert_eq!(app.commands[0].command, "ls -lah");
    assert_eq!(app.commands[0].tags, vec!["test".to_string(), "updated".to_string()]);
    assert_eq!(app.commands[0].id, original_command.id);

    Ok(())
}

#[test]
fn test_app_help_mode() -> Result<()> {
    let (mut db, _dir) = create_test_db()?;
    let mut commands = create_test_commands();
    
    // Add commands to the database first
    for cmd in &mut commands {
        cmd.id = Some(db.add_command(cmd)?);
    }
    
    let mut app = App::new(commands.clone(), &mut db, false);

    // Initial state
    assert_eq!(app.show_help, false);

    // Toggle help mode on
    app.show_help = true;
    assert_eq!(app.show_help, true);

    // Toggle help mode off
    app.show_help = false;
    assert_eq!(app.show_help, false);

    // Verify that help mode doesn't affect other app state
    assert_eq!(app.commands.len(), 3);
    assert_eq!(app.filtered_commands.len(), 3);
    assert_eq!(app.selected, None);
    assert_eq!(app.message, None);
    assert_eq!(app.filter_text, "");
    assert_eq!(app.confirm_delete, None);
    assert_eq!(app.debug_mode, false);

    Ok(())
}