Skip to content

Commit f1681ee

Browse files
cfsmp3claude
andcommitted
fix(args): Add support for legacy -1, -2, -12 numeric options
Map legacy CEA-608 field extraction options to their modern equivalent: - -1 → --output-field=1 (extract field 1 only) - -2 → --output-field=2 (extract field 2 only) - -12 → --output-field=12 (extract both fields) These options are documented in the help text and were commonly used but stopped working after the Rust argument parser migration. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent 031f463 commit f1681ee

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

src/rust/src/lib.rs

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -618,12 +618,20 @@ extern "C" fn ccxr_close_handle(handle: RawHandle) {
618618
/// - Double-dash options (e.g., `--quiet`) are left unchanged
619619
/// - Single-letter short options (e.g., `-o`) are left unchanged
620620
/// - Non-option arguments (e.g., `file.ts`) are left unchanged
621-
/// - Numeric options (e.g., `-1`, `-12`) are left unchanged (these are valid short options)
621+
/// - Numeric options `-1`, `-2`, `-12` are converted to `--output-field=N` for CEA-608 field selection
622622
fn normalize_legacy_option(arg: String) -> String {
623+
// Handle legacy numeric options for CEA-608 field extraction
624+
// These map to --output-field which is the modern equivalent
625+
match arg.as_str() {
626+
"-1" => return "--output-field=1".to_string(),
627+
"-2" => return "--output-field=2".to_string(),
628+
"-12" => return "--output-field=12".to_string(),
629+
_ => {}
630+
}
631+
623632
// Check if it's a single-dash option with multiple characters (e.g., -quiet)
624633
// but not a short option with a value (e.g., -o filename)
625634
// Single-letter options like -o, -s should be left unchanged
626-
// Numeric options like -1, -12 should also be left unchanged
627635
if arg.starts_with('-')
628636
&& !arg.starts_with("--")
629637
&& arg.len() > 2
@@ -843,12 +851,18 @@ mod test {
843851

844852
#[test]
845853
fn test_normalize_legacy_option_numeric_options() {
846-
// Numeric options should remain unchanged (these are valid ccextractor options)
847-
assert_eq!(normalize_legacy_option("-1".to_string()), "-1".to_string());
848-
assert_eq!(normalize_legacy_option("-2".to_string()), "-2".to_string());
854+
// Legacy numeric options for CEA-608 field selection are converted to --output-field
855+
assert_eq!(
856+
normalize_legacy_option("-1".to_string()),
857+
"--output-field=1".to_string()
858+
);
859+
assert_eq!(
860+
normalize_legacy_option("-2".to_string()),
861+
"--output-field=2".to_string()
862+
);
849863
assert_eq!(
850864
normalize_legacy_option("-12".to_string()),
851-
"-12".to_string()
865+
"--output-field=12".to_string()
852866
);
853867
}
854868

0 commit comments

Comments
 (0)