kelora 1.5.0

A command-line log analysis tool with embedded Rhai scripting
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
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
// tests/context_integration_test.rs
use std::io::Write;
use std::process::{Command, Stdio};
use tempfile::NamedTempFile;

/// Helper function to run kelora with given arguments and input via stdin
fn run_kelora_with_input(args: &[&str], input: &str) -> (String, String, i32) {
    // Use CARGO_BIN_EXE_kelora env var set by cargo during test runs
    // This works correctly for regular builds, coverage builds, and custom target dirs
    let binary_path = env!("CARGO_BIN_EXE_kelora");

    let mut cmd = Command::new(binary_path)
        .args(args)
        .stdin(Stdio::piped())
        .stdout(Stdio::piped())
        .stderr(Stdio::piped())
        .spawn()
        .expect("Failed to start kelora");

    // Write input to stdin
    if let Some(stdin) = cmd.stdin.as_mut() {
        stdin
            .write_all(input.as_bytes())
            .expect("Failed to write to stdin");
    }

    let output = cmd.wait_with_output().expect("Failed to read output");

    (
        String::from_utf8_lossy(&output.stdout).to_string(),
        String::from_utf8_lossy(&output.stderr).to_string(),
        output.status.code().unwrap_or(-1),
    )
}

/// Helper function to run kelora with a temporary file
fn _run_kelora_with_file(args: &[&str], file_content: &str) -> (String, String, i32) {
    let mut temp_file = NamedTempFile::new().expect("Failed to create temp file");
    temp_file
        .write_all(file_content.as_bytes())
        .expect("Failed to write to temp file");

    let mut full_args = args.to_vec();
    full_args.push(temp_file.path().to_str().unwrap());

    // Use CARGO_BIN_EXE_kelora env var set by cargo during test runs
    // This works correctly for regular builds, coverage builds, and custom target dirs
    let binary_path = env!("CARGO_BIN_EXE_kelora");

    let cmd = Command::new(binary_path)
        .args(&full_args)
        .stdout(Stdio::piped())
        .stderr(Stdio::piped())
        .output()
        .expect("Failed to execute kelora");

    (
        String::from_utf8_lossy(&cmd.stdout).to_string(),
        String::from_utf8_lossy(&cmd.stderr).to_string(),
        cmd.status.code().unwrap_or(-1),
    )
}

// Test data for context tests
const SAMPLE_JSON_LOGS: &str = r#"{"level": "info", "msg": "normal message 1", "ts": "2024-01-01T10:00:01Z"}
{"level": "debug", "msg": "debug message", "ts": "2024-01-01T10:00:02Z"}
{"level": "error", "msg": "ERROR: something went wrong", "ts": "2024-01-01T10:00:03Z"}
{"level": "info", "msg": "normal message 2", "ts": "2024-01-01T10:00:04Z"}
{"level": "warn", "msg": "warning message", "ts": "2024-01-01T10:00:05Z"}
{"level": "info", "msg": "normal message 3", "ts": "2024-01-01T10:00:06Z"}"#;

// VALIDATION TESTS

#[test]
fn test_context_requires_filtering() {
    let (stdout, stderr, exit_code) =
        run_kelora_with_input(&["-f", "json", "-A", "1"], SAMPLE_JSON_LOGS);

    assert_ne!(exit_code, 0, "Context without filtering should fail");
    assert!(
        stderr.contains("Context options (-A, -B, -C) require active filtering"),
        "Should show context validation error message"
    );
    assert!(
        stderr.contains("shown around matches") && stderr.contains("--filter"),
        "Should explain why context needs filtering and how to add it: {}",
        stderr
    );
    assert_eq!(
        stdout.trim(),
        "",
        "No output should be produced on validation error"
    );
}

#[test]
fn test_context_before_requires_filtering() {
    let (_stdout, stderr, exit_code) =
        run_kelora_with_input(&["-f", "json", "-B", "2"], SAMPLE_JSON_LOGS);

    assert_ne!(exit_code, 0, "Before context without filtering should fail");
    assert!(
        stderr.contains("Context options (-A, -B, -C) require active filtering"),
        "Should show context validation error message"
    );
    assert!(
        stderr.contains("shown around matches"),
        "Should explain why context needs filtering: {}",
        stderr
    );
}

#[test]
fn test_context_combined_requires_filtering() {
    let (_stdout, stderr, exit_code) =
        run_kelora_with_input(&["-f", "json", "-C", "1"], SAMPLE_JSON_LOGS);

    assert_ne!(
        exit_code, 0,
        "Combined context without filtering should fail"
    );
    assert!(
        stderr.contains("Context options (-A, -B, -C) require active filtering"),
        "Should show context validation error message"
    );
    assert!(
        stderr.contains("--levels") && stderr.contains("--since"),
        "Should suggest common filtering flags: {}",
        stderr
    );
}

#[test]
fn test_context_with_filter_succeeds() {
    let (stdout, _stderr, exit_code) = run_kelora_with_input(
        &["-f", "json", "--filter", "e.level == \"error\"", "-A", "1"],
        SAMPLE_JSON_LOGS,
    );

    assert_eq!(exit_code, 0, "Context with filtering should succeed");
    assert!(
        !stdout.trim().is_empty(),
        "Should produce output with filtering"
    );
}

#[test]
fn test_context_with_levels_succeeds() {
    let (stdout, _stderr, exit_code) = run_kelora_with_input(
        &["-f", "json", "--levels", "error", "-B", "1"],
        SAMPLE_JSON_LOGS,
    );

    assert_eq!(exit_code, 0, "Context with level filtering should succeed");
    assert!(
        !stdout.trim().is_empty(),
        "Should produce output with level filtering"
    );
}

// FORMATTING AND PREFIX TESTS

#[test]
fn test_context_prefix_formatting() {
    let (stdout, _stderr, exit_code) = run_kelora_with_input(
        &[
            "-f",
            "json",
            "--filter",
            "e.level == \"error\"",
            "-A",
            "1",
            "--no-color",
        ],
        SAMPLE_JSON_LOGS,
    );

    assert_eq!(exit_code, 0, "Context formatting should succeed");

    let lines: Vec<&str> = stdout.trim().split('\n').collect();
    assert!(!lines.is_empty(), "Should have output lines");

    // Check that the error line has a match prefix (*)
    let has_match_prefix = lines
        .iter()
        .any(|line| line.starts_with("* ") && line.contains("ERROR: something went wrong"));
    assert!(has_match_prefix, "Error line should have match prefix (*)");
}

#[test]
fn test_context_without_prefix_when_disabled() {
    let (stdout, _stderr, exit_code) = run_kelora_with_input(
        &[
            "-f",
            "json",
            "--filter",
            "e.level == \"error\"",
            "--no-color",
        ],
        SAMPLE_JSON_LOGS,
    );

    assert_eq!(exit_code, 0, "Filtering without context should succeed");

    let lines: Vec<&str> = stdout.trim().split('\n').collect();
    assert!(!lines.is_empty(), "Should have output lines");

    // Check that without context options, there should be no prefix
    let has_no_prefix = lines.iter().any(|line| {
        !line.starts_with("* ")
            && !line.starts_with("/ ")
            && !line.starts_with("\\ ")
            && line.contains("ERROR: something went wrong")
    });
    assert!(
        has_no_prefix,
        "Without context options, lines should have no prefix"
    );
}

#[test]
fn test_after_context_option() {
    let (stdout, _stderr, exit_code) = run_kelora_with_input(
        &[
            "-f",
            "json",
            "--filter",
            "e.level == \"error\"",
            "-A",
            "1",
            "--no-color",
        ],
        SAMPLE_JSON_LOGS,
    );

    assert_eq!(exit_code, 0, "After context should succeed");
    assert!(!stdout.trim().is_empty(), "Should produce output");

    // Verify that the match line has the * prefix
    assert!(stdout.contains("* "), "Should have match prefix");
}

#[test]
fn test_before_context_option() {
    let (stdout, _stderr, exit_code) = run_kelora_with_input(
        &[
            "-f",
            "json",
            "--filter",
            "e.level == \"error\"",
            "-B",
            "1",
            "--no-color",
        ],
        SAMPLE_JSON_LOGS,
    );

    assert_eq!(exit_code, 0, "Before context should succeed");
    assert!(!stdout.trim().is_empty(), "Should produce output");

    // Verify that the match line has the * prefix
    assert!(stdout.contains("* "), "Should have match prefix");
}

#[test]
fn test_combined_context_option() {
    let (stdout, _stderr, exit_code) = run_kelora_with_input(
        &[
            "-f",
            "json",
            "--filter",
            "e.level == \"error\"",
            "-C",
            "1",
            "--no-color",
        ],
        SAMPLE_JSON_LOGS,
    );

    assert_eq!(exit_code, 0, "Combined context should succeed");
    assert!(!stdout.trim().is_empty(), "Should produce output");

    // Verify that the match line has the * prefix
    assert!(stdout.contains("* "), "Should have match prefix");
}

// FILTERING MODES TESTS

#[test]
fn test_context_with_level_filtering() {
    let (stdout, _stderr, exit_code) = run_kelora_with_input(
        &["-f", "json", "-l", "error,warn", "-A", "1", "--no-color"],
        SAMPLE_JSON_LOGS,
    );

    assert_eq!(exit_code, 0, "Context with level filtering should succeed");

    let lines: Vec<&str> = stdout.trim().split('\n').collect();
    assert!(!lines.is_empty(), "Should have output lines");

    // Should have both error and warning lines with match prefixes
    let has_error_match = lines
        .iter()
        .any(|line| line.starts_with("* ") && line.contains("ERROR: something went wrong"));
    let has_warn_match = lines
        .iter()
        .any(|line| line.starts_with("* ") && line.contains("warning message"));

    assert!(has_error_match, "Should have error line with match prefix");
    assert!(has_warn_match, "Should have warning line with match prefix");
}

#[test]
fn test_context_with_exclude_levels() {
    let (stdout, _stderr, exit_code) = run_kelora_with_input(
        &["-f", "json", "-L", "debug,info", "-B", "1", "--no-color"],
        SAMPLE_JSON_LOGS,
    );

    assert_eq!(exit_code, 0, "Context with exclude levels should succeed");

    let output = stdout.trim();
    assert!(!output.is_empty(), "Should have output");

    // Should exclude debug and info, so only error and warn should appear
    assert!(
        output.contains("ERROR: something went wrong"),
        "Should include error"
    );
    assert!(output.contains("warning message"), "Should include warning");
    assert!(!output.contains("debug message"), "Should exclude debug");
    assert!(
        !output.contains("normal message"),
        "Should exclude info messages"
    );
}

#[test]
fn test_context_with_custom_filter() {
    let (stdout, _stderr, exit_code) = run_kelora_with_input(
        &[
            "-f",
            "json",
            "--filter",
            "e.msg.contains(\"ERROR\")",
            "-C",
            "1",
            "--no-color",
        ],
        SAMPLE_JSON_LOGS,
    );

    assert_eq!(exit_code, 0, "Context with custom filter should succeed");

    let lines: Vec<&str> = stdout.trim().split('\n').collect();
    assert!(!lines.is_empty(), "Should have output lines");

    // Should find the error message
    let has_error_match = lines
        .iter()
        .any(|line| line.starts_with("* ") && line.contains("ERROR: something went wrong"));
    assert!(
        has_error_match,
        "Should find error message with match prefix"
    );
}

// DIFFERENT INPUT FORMATS TESTS

#[test]
fn test_context_with_line_format() {
    let line_input = "normal line 1\nerror occurred here\nnormal line 2\n";

    let (stdout, _stderr, exit_code) = run_kelora_with_input(
        &[
            "-f",
            "line",
            "--filter",
            "e.line.contains(\"error\")",
            "-A",
            "1",
            "--no-color",
        ],
        line_input,
    );

    assert_eq!(exit_code, 0, "Context with line format should succeed");
    assert!(!stdout.trim().is_empty(), "Should produce output");
    assert!(stdout.contains("* "), "Should have match prefix");
}

#[test]
fn test_context_with_logfmt_format() {
    let logfmt_input = "level=info msg=\"normal message\"\nlevel=error msg=\"error occurred\"\nlevel=info msg=\"another message\"\n";

    let (stdout, _stderr, exit_code) = run_kelora_with_input(
        &[
            "-f",
            "logfmt",
            "--filter",
            "e.level == \"error\"",
            "-B",
            "1",
            "--no-color",
        ],
        logfmt_input,
    );

    assert_eq!(exit_code, 0, "Context with logfmt format should succeed");
    assert!(!stdout.trim().is_empty(), "Should produce output");
    assert!(stdout.contains("* "), "Should have match prefix");
}

// STRUCTURED OUTPUT FORMATS TESTS

#[test]
fn test_context_preserves_json_output_structure() {
    let (stdout, _stderr, exit_code) = run_kelora_with_input(
        &[
            "-f",
            "json",
            "-F",
            "json",
            "--filter",
            "e.level == \"error\"",
            "-A",
            "1",
        ],
        SAMPLE_JSON_LOGS,
    );

    assert_eq!(exit_code, 0, "Context with JSON output should succeed");

    let lines: Vec<&str> = stdout.trim().split('\n').collect();
    assert!(!lines.is_empty(), "Should have output lines");

    // All lines should be valid JSON (no prefixes in JSON output)
    for line in lines {
        if !line.trim().is_empty() {
            let parse_result: Result<serde_json::Value, _> = serde_json::from_str(line);
            assert!(
                parse_result.is_ok(),
                "JSON output should be valid JSON: {}",
                line
            );
        }
    }
}

#[test]
fn test_context_with_csv_output() {
    let (stdout, _stderr, exit_code) = run_kelora_with_input(
        &[
            "-f",
            "json",
            "-F",
            "csv",
            "--keys",
            "level,msg",
            "--filter",
            "e.level == \"error\"",
            "-A",
            "1",
        ],
        SAMPLE_JSON_LOGS,
    );

    assert_eq!(exit_code, 0, "Context with CSV output should succeed");
    assert!(!stdout.trim().is_empty(), "Should produce output");

    // CSV output should not have context prefixes
    let lines: Vec<&str> = stdout.trim().split('\n').collect();
    for line in lines {
        assert!(
            !line.starts_with("* "),
            "CSV output should not have context prefixes"
        );
        assert!(
            !line.starts_with("/ "),
            "CSV output should not have context prefixes"
        );
        assert!(
            !line.starts_with("\\ "),
            "CSV output should not have context prefixes"
        );
    }
}

// PARALLEL PROCESSING TESTS

#[test]
fn test_context_with_parallel_processing() {
    let (stdout, _stderr, exit_code) = run_kelora_with_input(
        &[
            "-f",
            "json",
            "--filter",
            "e.level == \"error\"",
            "-A",
            "1",
            "--parallel",
            "--no-color",
        ],
        SAMPLE_JSON_LOGS,
    );

    assert_eq!(
        exit_code, 0,
        "Context with parallel processing should succeed"
    );
    assert!(
        !stdout.trim().is_empty(),
        "Should produce output with parallel processing"
    );

    // Should still have match prefixes in parallel mode
    assert!(
        stdout.contains("* "),
        "Should have match prefix in parallel mode"
    );
}

#[test]
fn test_context_with_parallel_and_unordered() {
    let (stdout, _stderr, exit_code) = run_kelora_with_input(
        &[
            "-f",
            "json",
            "--filter",
            "e.level == \"error\"",
            "-C",
            "1",
            "--parallel",
            "--unordered",
            "--no-color",
        ],
        SAMPLE_JSON_LOGS,
    );

    assert_eq!(
        exit_code, 0,
        "Context with parallel unordered should succeed"
    );
    assert!(!stdout.trim().is_empty(), "Should produce output");

    // Should still have match prefixes even with unordered output
    assert!(
        stdout.contains("* "),
        "Should have match prefix with unordered output"
    );
}

// EDGE CASES AND ERROR HANDLING

#[test]
fn test_context_with_zero_value() {
    let (stdout, _stderr, exit_code) = run_kelora_with_input(
        &["-f", "json", "--filter", "e.level == \"error\"", "-A", "0"],
        SAMPLE_JSON_LOGS,
    );

    assert_eq!(exit_code, 0, "Context with zero value should succeed");
    assert!(!stdout.trim().is_empty(), "Should produce output");

    // With -A 0, context is disabled so no prefixes should appear
    assert!(
        !stdout.contains("* "),
        "Should have no prefix with -A 0 (context disabled)"
    );
    assert!(
        !stdout.contains("/ "),
        "Should have no prefix with -A 0 (context disabled)"
    );
    assert!(
        !stdout.contains("\\ "),
        "Should have no prefix with -A 0 (context disabled)"
    );
}

#[test]
fn test_context_with_large_value() {
    let (stdout, _stderr, exit_code) = run_kelora_with_input(
        &[
            "-f",
            "json",
            "--filter",
            "e.level == \"error\"",
            "-B",
            "100",
        ],
        SAMPLE_JSON_LOGS,
    );

    assert_eq!(exit_code, 0, "Context with large value should succeed");
    assert!(!stdout.trim().is_empty(), "Should produce output");
}

#[test]
fn test_context_with_empty_input() {
    let (stdout, _stderr, exit_code) = run_kelora_with_input(
        &["-f", "json", "--filter", "e.level == \"error\"", "-C", "1"],
        "",
    );

    assert_eq!(exit_code, 0, "Context with empty input should succeed");
    assert_eq!(stdout.trim(), "", "Empty input should produce no output");
}

#[test]
fn test_context_with_no_matches() {
    let (stdout, _stderr, exit_code) = run_kelora_with_input(
        &[
            "-f",
            "json",
            "--filter",
            "e.level == \"critical\"",
            "-A",
            "2",
        ],
        SAMPLE_JSON_LOGS,
    );

    assert_eq!(exit_code, 0, "Context with no matches should succeed");
    assert_eq!(stdout.trim(), "", "No matches should produce no output");
}

// INTEGRATION WITH OTHER FEATURES

#[test]
fn test_context_with_brief_mode() {
    let (stdout, _stderr, exit_code) = run_kelora_with_input(
        &[
            "-f",
            "json",
            "--filter",
            "e.level == \"error\"",
            "-A",
            "1",
            "--brief",
            "--no-color",
        ],
        SAMPLE_JSON_LOGS,
    );

    assert_eq!(exit_code, 0, "Context with brief mode should succeed");
    assert!(!stdout.trim().is_empty(), "Should produce output");
    assert!(
        stdout.contains("* "),
        "Should have match prefix in brief mode"
    );
}

#[test]
fn test_context_with_take_limit() {
    let (stdout, _stderr, exit_code) = run_kelora_with_input(
        &[
            "-f",
            "json",
            "--filter",
            "e.level != \"\"",
            "-A",
            "1",
            "--take",
            "2",
            "--no-color",
        ],
        SAMPLE_JSON_LOGS,
    );

    assert_eq!(exit_code, 0, "Context with take limit should succeed");

    let lines: Vec<&str> = stdout.trim().split('\n').collect();
    assert!(lines.len() <= 2, "Should respect take limit");
}

#[test]
fn test_context_with_window_option() {
    let (stdout, _stderr, exit_code) = run_kelora_with_input(
        &[
            "-f",
            "json",
            "--filter",
            "e.level == \"error\"",
            "-C",
            "1",
            "--window",
            "5",
            "--no-color",
        ],
        SAMPLE_JSON_LOGS,
    );

    assert_eq!(exit_code, 0, "Context with window option should succeed");
    assert!(!stdout.trim().is_empty(), "Should produce output");
    assert!(
        stdout.contains("* "),
        "Should have match prefix with window option"
    );
}

#[test]
fn test_context_markers_suppressed_in_quiet_mode() {
    // Test that context markers (/, *, \, |) are suppressed when events are disabled
    let (stdout_normal, _stderr, exit_code) = run_kelora_with_input(
        &[
            "-f",
            "json",
            "--filter",
            "e.level == \"error\"",
            "-A",
            "1",
            "-B",
            "1",
            "--no-color",
        ],
        SAMPLE_JSON_LOGS,
    );

    assert_eq!(exit_code, 0, "Context without quiet should succeed");
    assert!(
        stdout_normal.contains("/ "),
        "Should have before context marker without quiet"
    );
    assert!(
        stdout_normal.contains("* "),
        "Should have match marker without quiet"
    );
    assert!(
        stdout_normal.contains("\\ "),
        "Should have after context marker without quiet"
    );

    // Test -q (suppress events) - output should be empty
    let (stdout_q, _stderr, exit_code) = run_kelora_with_input(
        &[
            "-f",
            "json",
            "--filter",
            "e.level == \"error\"",
            "-A",
            "1",
            "-B",
            "1",
            "-q",
            "--no-color",
        ],
        SAMPLE_JSON_LOGS,
    );

    assert_eq!(exit_code, 0, "Context with -q should succeed");
    assert!(
        stdout_q.trim().is_empty(),
        "No events should be emitted with -q"
    );

    // Test --silent (suppress all terminal output) - should produce no events or diagnostics
    let (stdout_silent, stderr_silent, exit_code) = run_kelora_with_input(
        &[
            "-f",
            "json",
            "--filter",
            "e.level == \"error\"",
            "-A",
            "1",
            "-B",
            "1",
            "--silent",
            "--no-color",
        ],
        SAMPLE_JSON_LOGS,
    );

    assert_eq!(exit_code, 0, "Context with --silent should succeed");
    assert!(
        stdout_silent.trim().is_empty(),
        "No events should be produced with --silent"
    );
    assert!(
        stderr_silent.trim().is_empty(),
        "No diagnostics should be produced with --silent"
    );
}