string_pipeline 0.14.0

A flexible, template-driven string transformation pipeline for Rust.
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
use std::io::Write;
use std::process::Command;
use tempfile::NamedTempFile;

const BINARY_NAME: &str = "string-pipeline";

/// Helper function to run the CLI with arguments and return output
fn run_cli(args: &[&str]) -> std::process::Output {
    Command::new("cargo")
        .args(["run", "--bin", BINARY_NAME, "--"])
        .args(args)
        .output()
        .expect("Failed to execute command")
}

/// Helper function to run CLI with stdin input
fn run_cli_with_stdin(args: &[&str], stdin_input: &str) -> std::process::Output {
    let mut cmd = Command::new("cargo")
        .args(["run", "--bin", BINARY_NAME, "--"])
        .args(args)
        .stdin(std::process::Stdio::piped())
        .stdout(std::process::Stdio::piped())
        .stderr(std::process::Stdio::piped())
        .spawn()
        .expect("Failed to spawn command");

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

    cmd.wait_with_output().expect("Failed to read stdout")
}

/// Helper function to create a temporary file with content
fn create_temp_file(content: &str) -> NamedTempFile {
    let mut file = NamedTempFile::new().expect("Failed to create temp file");
    file.write_all(content.as_bytes())
        .expect("Failed to write to temp file");
    file
}

// ============================================================================
// BASIC FUNCTIONALITY TESTS
// ============================================================================
#[test]
fn test_basic_template_and_input() {
    let output = run_cli(&["{upper}", "hello world"]);
    assert!(output.status.success());
    assert_eq!(
        String::from_utf8_lossy(&output.stdout).trim(),
        "HELLO WORLD"
    );
}

#[test]
fn test_stdin_input() {
    let output = run_cli_with_stdin(&["{lower}"], "HELLO WORLD");
    assert!(output.status.success());
    assert_eq!(
        String::from_utf8_lossy(&output.stdout).trim(),
        "hello world"
    );
}

#[test]
fn test_stdin_with_complex_pipeline() {
    let output = run_cli_with_stdin(&["{split:,:..|map:{upper}|join:-}"], "apple,banana,cherry");
    assert!(output.status.success());
    assert_eq!(
        String::from_utf8_lossy(&output.stdout).trim(),
        "APPLE-BANANA-CHERRY"
    );
}

#[test]
fn test_complex_pipeline() {
    let output = run_cli(&["{split:,:..|map:{upper}|join:-}", "hello,world,test"]);
    assert!(output.status.success());
    assert_eq!(
        String::from_utf8_lossy(&output.stdout).trim(),
        "HELLO-WORLD-TEST"
    );
}

// ============================================================================
// TEMPLATE COMPOSITION TESTS
// ============================================================================
#[test]
fn test_template_basic() {
    let output = run_cli(&["Hello {upper} World!", "test"]);
    assert!(output.status.success());
    assert_eq!(
        String::from_utf8_lossy(&output.stdout).trim(),
        "Hello TEST World!"
    );
}

#[test]
fn test_template_multiple_sections() {
    let output = run_cli(&["First: {split:,:0} Last: {split:,:1}", "apple,banana"]);
    assert!(output.status.success());
    assert_eq!(
        String::from_utf8_lossy(&output.stdout).trim(),
        "First: apple Last: banana"
    );
}

#[test]
fn test_template_with_complex_operations() {
    let output = run_cli(&[
        "Count: {split:,:..|map:{upper}|join:-} Items: {split:,:1..3|join:;}",
        "a,b,c,d,e",
    ]);
    assert!(output.status.success());
    assert_eq!(
        String::from_utf8_lossy(&output.stdout).trim(),
        "Count: A-B-C-D-E Items: b;c"
    );
}

#[test]
fn test_template_literal_only() {
    let output = run_cli(&["Just plain text", "ignored"]);
    assert!(output.status.success());
    assert_eq!(
        String::from_utf8_lossy(&output.stdout).trim(),
        "Just plain text"
    );
}

#[test]
fn test_template_consecutive_templates() {
    let output = run_cli(&["{upper}{lower}", "TeSt"]);
    assert!(output.status.success());
    assert_eq!(String::from_utf8_lossy(&output.stdout).trim(), "TESTtest");
}

// ============================================================================
// FILE I/O TESTS
// ============================================================================

#[test]
fn test_template_file_option() {
    let template_file = create_temp_file("{upper}");
    let output = run_cli_with_stdin(
        &["--template-file", template_file.path().to_str().unwrap()],
        "hello world",
    );
    assert!(output.status.success());
    assert_eq!(
        String::from_utf8_lossy(&output.stdout).trim(),
        "HELLO WORLD"
    );
}

#[test]
fn test_template_file_template() {
    let template_file = create_temp_file("Prefix: {upper} Suffix: {lower}");
    let output = run_cli_with_stdin(
        &["--template-file", template_file.path().to_str().unwrap()],
        "test",
    );
    assert!(output.status.success());
    assert_eq!(
        String::from_utf8_lossy(&output.stdout).trim(),
        "Prefix: TEST Suffix: test"
    );
}

#[test]
fn test_input_file_option() {
    let input_file = create_temp_file("hello world");
    let output = run_cli(&[
        "{upper}",
        "--input-file",
        input_file.path().to_str().unwrap(),
    ]);
    assert!(output.status.success());
    assert_eq!(
        String::from_utf8_lossy(&output.stdout).trim(),
        "HELLO WORLD"
    );
}

#[test]
fn test_both_template_and_input_files() {
    let template_file = create_temp_file("{upper}");
    let input_file = create_temp_file("hello world");
    let output = run_cli(&[
        "--template-file",
        template_file.path().to_str().unwrap(),
        "--input-file",
        input_file.path().to_str().unwrap(),
    ]);
    assert!(output.status.success());
    assert_eq!(
        String::from_utf8_lossy(&output.stdout).trim(),
        "HELLO WORLD"
    );
}

#[test]
fn test_input_file_with_template() {
    let input_file = create_temp_file("apple,banana");
    let output = run_cli(&[
        "First: {split:,:0} Second: {split:,:1}",
        "--input-file",
        input_file.path().to_str().unwrap(),
    ]);
    assert!(output.status.success());
    assert_eq!(
        String::from_utf8_lossy(&output.stdout).trim(),
        "First: apple Second: banana"
    );
}

// ============================================================================
// DEBUG AND QUIET FLAG TESTS
// ============================================================================
#[test]
fn test_debug_flag() {
    let output = run_cli(&["--debug", "{upper}", "hello"]);
    assert!(output.status.success());
    // Debug flag should not cause failure, output should still be correct
    assert_eq!(String::from_utf8_lossy(&output.stdout).trim(), "HELLO");
}

#[test]
fn test_debug_flag_with_template() {
    let output = run_cli(&["--debug", "Result: {upper}", "hello"]);
    assert!(output.status.success());
    assert_eq!(
        String::from_utf8_lossy(&output.stdout).trim(),
        "Result: HELLO"
    );
}

#[test]
fn test_quiet_suppresses_debug() {
    let output = run_cli(&["--quiet", "--debug", "{split:,:..|map:{upper}}", "a,b"]);
    assert!(output.status.success());
    let stdout = String::from_utf8_lossy(&output.stdout);
    // Should only have the result, no DEBUG: messages
    assert_eq!(stdout.trim(), "A,B");
    assert!(!stdout.contains("DEBUG:"));
}

#[test]
fn test_quiet_suppresses_inline_debug() {
    let output = run_cli(&["--quiet", "{!split:,:..|map:{upper}}", "a,b"]);
    assert!(output.status.success());
    let stdout = String::from_utf8_lossy(&output.stdout);
    // Should only have the result, no DEBUG: messages
    assert_eq!(stdout.trim(), "A,B");
    assert!(!stdout.contains("DEBUG:"));
}

#[test]
fn test_quiet_suppresses_debug_stderr() {
    let output = run_cli(&["--quiet", "--debug", "{split:,:..|map:{upper}}", "a,b"]);
    assert!(output.status.success());
    let stdout = String::from_utf8_lossy(&output.stdout);
    let stderr = String::from_utf8_lossy(&output.stderr);
    // Should only have the result, no DEBUG: messages
    assert_eq!(stdout.trim(), "A,B");
    assert!(!stderr.contains("DEBUG:"));
}

#[test]
fn test_quiet_suppresses_inline_debug_stderr() {
    let output = run_cli(&["--quiet", "{!split:,:..|map:{upper}}", "a,b"]);
    assert!(output.status.success());
    let stdout = String::from_utf8_lossy(&output.stdout);
    let stderr = String::from_utf8_lossy(&output.stderr);
    // Should only have the result, no DEBUG: messages
    assert_eq!(stdout.trim(), "A,B");
    assert!(!stderr.contains("DEBUG:"));
}

#[test]
fn test_debug_without_quiet_shows_stderr() {
    let output = run_cli(&["--debug", "{split:,:..|map:{upper}}", "a,b"]);
    assert!(output.status.success());
    let stdout = String::from_utf8_lossy(&output.stdout);
    let stderr = String::from_utf8_lossy(&output.stderr);
    // Should have the result
    assert_eq!(stdout.trim(), "A,B");
    // Should have DEBUG messages on stderr
    assert!(stderr.contains("DEBUG:"));
}

#[test]
fn test_inline_debug_markers_show_debug() {
    let output = run_cli(&["{!upper}", "hello"]);
    assert!(output.status.success());
    let stdout = String::from_utf8_lossy(&output.stdout);
    let stderr = String::from_utf8_lossy(&output.stderr);

    // Should have the correct result
    assert_eq!(stdout.trim(), "HELLO");
    // Should have DEBUG messages on stderr due to ! prefix
    assert!(stderr.contains("DEBUG:"));
    assert!(stderr.contains("MULTI-TEMPLATE START"));
}

#[test]
fn test_inline_debug_markers_complex_template() {
    let output = run_cli(&["{!split:,:..|map:{upper}}", "hello,world"]);
    assert!(output.status.success());
    let stdout = String::from_utf8_lossy(&output.stdout);
    let stderr = String::from_utf8_lossy(&output.stderr);

    // Should have the correct result
    assert_eq!(stdout.trim(), "HELLO,WORLD");
    // Should have detailed DEBUG messages on stderr
    assert!(stderr.contains("DEBUG:"));
    assert!(stderr.contains("MULTI-TEMPLATE START"));
}

#[test]
fn test_cli_debug_flag_shows_debug() {
    let output = run_cli(&["--debug", "{split:,:..|map:{upper}}", "hello,world"]);
    assert!(output.status.success());
    let stdout = String::from_utf8_lossy(&output.stdout);
    let stderr = String::from_utf8_lossy(&output.stderr);

    // Should have the correct result
    assert_eq!(stdout.trim(), "HELLO,WORLD");
    // Should have DEBUG messages on stderr due to --debug flag
    assert!(stderr.contains("DEBUG:"));
    assert!(stderr.contains("MULTI-TEMPLATE START"));
}

#[test]
fn test_both_inline_and_cli_debug() {
    let output = run_cli(&["--debug", "{!split:,:..|map:{upper}}", "hello,world"]);
    assert!(output.status.success());
    let stdout = String::from_utf8_lossy(&output.stdout);
    let stderr = String::from_utf8_lossy(&output.stderr);

    // Should have the correct result
    assert_eq!(stdout.trim(), "HELLO,WORLD");
    // Should have DEBUG messages (both sources enable debug)
    assert!(stderr.contains("DEBUG:"));
    assert!(stderr.contains("MULTI-TEMPLATE START"));
}

// ============================================================================
// VALIDATION TESTS
// ============================================================================
#[test]
fn test_validate_flag() {
    let output = run_cli(&["--validate", "{upper}"]);
    assert!(output.status.success());
    assert_eq!(
        String::from_utf8_lossy(&output.stdout).trim(),
        "Template syntax is valid"
    );
}

#[test]
fn test_validate_template() {
    let output = run_cli(&["--validate", "Hello {upper} World!"]);
    assert!(output.status.success());
    assert_eq!(
        String::from_utf8_lossy(&output.stdout).trim(),
        "Template syntax is valid"
    );
}

#[test]
fn test_validate_invalid_template() {
    let output = run_cli(&["--validate", "{invalid_operation}"]);
    assert!(!output.status.success());
    let stderr = String::from_utf8_lossy(&output.stderr);
    assert!(stderr.contains("Error parsing template"));
}

#[test]
fn test_validate_complex_template() {
    let output = run_cli(&["--validate", "{split:,:..|map:{upper|append:!}|join:-}"]);
    assert!(output.status.success());
    assert_eq!(
        String::from_utf8_lossy(&output.stdout).trim(),
        "Template syntax is valid"
    );
}

#[test]
fn test_quiet_flag() {
    let output = run_cli(&["--quiet", "--validate", "{upper}"]);
    assert!(output.status.success());
    assert_eq!(String::from_utf8_lossy(&output.stdout).trim(), "");
}

#[test]
fn test_validate_with_template_file() {
    let template_file = create_temp_file("Hello {upper} World!");
    let output = run_cli(&[
        "--validate",
        "--template-file",
        template_file.path().to_str().unwrap(),
    ]);
    assert!(output.status.success());
    assert_eq!(
        String::from_utf8_lossy(&output.stdout).trim(),
        "Template syntax is valid"
    );
}

#[test]
fn test_default_string_output() {
    // Test that default behavior outputs raw string
    let output = run_cli(&["{split:,:..|join:,}", "a,b,c"]);
    assert!(output.status.success());
    assert_eq!(String::from_utf8_lossy(&output.stdout).trim(), "a,b,c");
}

// ============================================================================
// HELP AND INFORMATION TESTS
// ============================================================================
#[test]
fn test_list_operations_flag() {
    let output = run_cli(&["--list-operations"]);
    assert!(output.status.success());
    let stdout = String::from_utf8_lossy(&output.stdout);
    assert!(stdout.contains("Available Operations:"));
    assert!(stdout.contains("split:"));
    assert!(stdout.contains("upper"));
    assert!(stdout.contains("lower"));
}

#[test]
fn test_syntax_help_flag() {
    let output = run_cli(&["--syntax-help"]);
    assert!(output.status.success());
    let stdout = String::from_utf8_lossy(&output.stdout);
    assert!(stdout.contains("Template Syntax Help:"));
    assert!(stdout.contains("BASIC SYNTAX:"));
    assert!(stdout.contains("RANGE SYNTAX:"));
}

#[test]
fn test_help_when_no_arguments() {
    let output = run_cli(&["--help"]);
    // Test explicit help flag instead of relying on no-args behavior
    let stdout = String::from_utf8_lossy(&output.stdout);
    assert!(stdout.contains("Usage:"));
}

#[test]
fn test_version_flag() {
    let output = run_cli(&["--version"]);
    assert!(output.status.success());
    let stdout = String::from_utf8_lossy(&output.stdout);
    assert!(stdout.contains("string-pipeline"));
}

// ============================================================================
// SHORT FLAGS TESTS
// ============================================================================
#[test]
fn test_short_flags() {
    // Test short versions of flags
    let template_file = create_temp_file("{upper}");
    let input_file = create_temp_file("hello world");

    let output = run_cli(&[
        "-t",
        template_file.path().to_str().unwrap(),
        "-f",
        input_file.path().to_str().unwrap(),
        "-d", // debug
        "-q", // quiet
    ]);
    assert!(output.status.success());
}

// ============================================================================
// ERROR HANDLING TESTS
// ============================================================================
#[test]
fn test_error_both_template_and_template_file() {
    let template_file = create_temp_file("{upper}");
    let output = run_cli(&[
        "{lower}",
        "--template-file",
        template_file.path().to_str().unwrap(),
        "hello",
    ]);
    assert!(!output.status.success());
    let stderr = String::from_utf8_lossy(&output.stderr);
    assert!(stderr.contains("Cannot specify both template argument and template file"));
}

#[test]
fn test_error_both_input_and_input_file() {
    let input_file = create_temp_file("hello");
    let output = run_cli(&[
        "{upper}",
        "world",
        "--input-file",
        input_file.path().to_str().unwrap(),
    ]);
    assert!(!output.status.success());
    let stderr = String::from_utf8_lossy(&output.stderr);
    assert!(stderr.contains("Cannot specify both input argument and input file"));
}

#[test]
fn test_invalid_template_syntax() {
    let output = run_cli(&["{unclosed_brace", "hello"]);
    assert!(!output.status.success());
    let stderr = String::from_utf8_lossy(&output.stderr);
    assert!(stderr.contains("Error parsing template"));
}

#[test]
fn test_nonexistent_template_file() {
    let output = run_cli(&["--template-file", "/nonexistent/file.txt"]);
    assert!(!output.status.success());
    let stderr = String::from_utf8_lossy(&output.stderr);
    assert!(stderr.contains("Error reading template file"));
}

#[test]
fn test_nonexistent_input_file() {
    let output = run_cli(&["{upper}", "--input-file", "/nonexistent/file.txt"]);
    assert!(!output.status.success());
    let stderr = String::from_utf8_lossy(&output.stderr);
    assert!(stderr.contains("Error reading input file"));
}

#[test]
fn test_missing_template_argument() {
    let output = run_cli(&[]);
    // Should show help when no arguments provided and no stdin
    let stdout = String::from_utf8_lossy(&output.stdout);
    assert!(stdout.contains("Usage:") || stdout.is_empty());
}

#[test]
fn test_template_runtime_error() {
    // Test a template that parses but fails at runtime
    let output = run_cli(&["{filter:[}", "test"]);
    assert!(!output.status.success());
    let stderr = String::from_utf8_lossy(&output.stderr);
    assert!(stderr.contains("Error formatting input"));
}

// ============================================================================
// EDGE CASES AND SPECIAL SCENARIOS
// ============================================================================
#[test]
fn test_empty_input() {
    let output = run_cli_with_stdin(&["{upper}"], "");
    assert!(output.status.success());
    assert_eq!(String::from_utf8_lossy(&output.stdout).trim(), "");
}

#[test]
fn test_empty_template_literal() {
    let output = run_cli(&["", "hello"]);
    assert!(output.status.success());
    assert_eq!(String::from_utf8_lossy(&output.stdout).trim(), "");
}

#[test]
fn test_multiline_input() {
    let input = "hello\nworld\ntest";
    let output = run_cli_with_stdin(&["{upper}"], input);
    assert!(output.status.success());
    let stdout_raw = String::from_utf8_lossy(&output.stdout);
    let stdout = stdout_raw.trim();
    assert!(stdout.contains("HELLO") && stdout.contains("WORLD") && stdout.contains("TEST"));
}

#[test]
fn test_unicode_input() {
    let output = run_cli(&["{upper}", "café naïve"]);
    assert!(output.status.success());
    assert_eq!(String::from_utf8_lossy(&output.stdout).trim(), "CAFÉ NAÏVE");
}

#[test]
fn test_unicode_in_template() {
    let output = run_cli(&["🎉 Result: {upper} 🎊", "café"]);
    assert!(output.status.success());
    assert_eq!(
        String::from_utf8_lossy(&output.stdout).trim(),
        "🎉 Result: CAFÉ 🎊"
    );
}

#[test]
fn test_special_characters_in_input() {
    let output = run_cli(&["{upper}", "hello @#$%^&*() world"]);
    assert!(output.status.success());
    assert_eq!(
        String::from_utf8_lossy(&output.stdout).trim(),
        "HELLO @#$%^&*() WORLD"
    );
}

#[test]
fn test_very_long_input() {
    let long_input = "word ".repeat(1000);
    let output = run_cli_with_stdin(&["{upper}"], &long_input);
    assert!(output.status.success());
    let result = String::from_utf8_lossy(&output.stdout);
    assert!(result.contains("WORD"));
    assert!(result.len() > 4000); // Should be roughly 5000 characters
}

#[test]
fn test_whitespace_preservation_in_template() {
    let output = run_cli(&["   Before   {trim}   After   ", "  test  "]);
    assert!(output.status.success());
    assert_eq!(
        String::from_utf8_lossy(&output.stdout).trim(),
        "Before   test   After"
    );
}

#[test]
fn test_template_with_literal_braces() {
    // Test that literal braces in templates work with proper escaping
    let output = run_cli(&["literal text {upper} more literal", "hello"]);
    assert!(output.status.success());
    assert_eq!(
        String::from_utf8_lossy(&output.stdout).trim(),
        "literal text HELLO more literal"
    );
}

#[test]
fn test_stdin_unavailable_no_input() {
    // This test simulates the case where no stdin is available and no input is provided
    // The behavior should be to show help
    let output = run_cli(&["{upper}"]);
    // Should either succeed with empty result or show help
    // The exact behavior may depend on the system
    assert!(output.status.success() || !output.status.success());
}

// ============================================================================
// COMBINATION AND INTEGRATION TESTS
// ============================================================================
#[test]
fn test_debug_and_validation_together() {
    let output = run_cli(&["--debug", "--validate", "{split:,:..|map:{upper}}"]);
    assert!(output.status.success());
    assert_eq!(
        String::from_utf8_lossy(&output.stdout).trim(),
        "Template syntax is valid"
    );
}

#[test]
fn test_file_input_with_debug() {
    let input_file = create_temp_file("hello,world");
    let output = run_cli(&[
        "--debug",
        "{split:,:..|map:{upper}|join:-}",
        "--input-file",
        input_file.path().to_str().unwrap(),
    ]);
    assert!(output.status.success());
    assert_eq!(
        String::from_utf8_lossy(&output.stdout).trim(),
        "HELLO-WORLD"
    );
    let stderr = String::from_utf8_lossy(&output.stderr);
    assert!(stderr.contains("DEBUG:"));
}

#[test]
fn test_template_file_with_template_and_validation() {
    let template_file = create_temp_file("Start: {split:,:0} End: {split:,:1}");
    let output = run_cli(&[
        "--validate",
        "--template-file",
        template_file.path().to_str().unwrap(),
    ]);
    assert!(output.status.success());
    assert_eq!(
        String::from_utf8_lossy(&output.stdout).trim(),
        "Template syntax is valid"
    );
}