Skip to content

Conversation

@cfsmp3
Copy link
Contributor

@cfsmp3 cfsmp3 commented Dec 20, 2025

Summary

  • Fixes issue where scripts using -quiet (single-dash) instead of --quiet (double-dash) would fail silently with exit code 7 and produce zero-length output files
  • Adds normalize_legacy_option() function that pre-processes command-line arguments to convert legacy single-dash long options to double-dash format before passing to clap
  • Maintains full backward compatibility with old scripts while preserving correct behavior for short options like -o

Root Cause

The Rust-based argument parser (clap) only accepts double-dash long options (--quiet), but old versions of ccextractor accepted single-dash (-quiet). When clap received -quiet, it parsed it as five individual short options -q -u -i -e -t. Since -q wasn't defined, it failed with exit code 7.

Users with scripts that redirected stderr (> /dev/null 2>&1) never saw the error message, causing the "intermittent" zero-length output described in the issue.

Changes

src/rust/src/lib.rs:

  • Added normalize_legacy_option() function that converts single-dash long options to double-dash
  • Pre-processes all arguments before passing to clap's parser
  • Added 6 unit tests covering all edge cases

Test Results

Test Case Before Fix After Fix
-quiet Exit code 7, no output Exit code 0, correct output ✓
--quiet Works Works ✓
-stdout Exit code 7 Works ✓
-autoprogram Exit code 7 Works ✓
Short options (-o) Works Works ✓
Numeric options (-1, -12) Works Works ✓

All 292 Rust tests pass (286 existing + 6 new).

Test plan

  • Verify -quiet now works (was failing before)
  • Verify --quiet still works
  • Verify short options like -o still work
  • Verify numeric options like -1, -12 still work
  • Run full Rust test suite
  • CI passes

Fixes #1576

🤖 Generated with Claude Code

cfsmp3 and others added 2 commits December 20, 2025 08:54
…CExtractor#1576)

Old versions of ccextractor accepted single-dash long options like
-quiet, -stdout, -autoprogram. The new Rust-based argument parser
(clap) only accepts double-dash options (--quiet, --stdout, etc.).

When users ran scripts with -quiet, clap parsed it as individual
short options -q -u -i -e -t and failed with exit code 7. Users
with stderr redirected never saw the error, causing silent failures
with zero-length output files.

This adds a normalize_legacy_option() function that pre-processes
arguments before passing them to clap:
- Single-dash long options (e.g., -quiet) convert to --quiet
- Double-dash options remain unchanged
- Short options like -o remain unchanged
- Numeric options like -1, -12 remain unchanged

Includes 6 unit tests for the new function.

Fixes CCExtractor#1576

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@cfsmp3 cfsmp3 merged commit d024323 into CCExtractor:master Dec 20, 2025
17 of 19 checks passed
@cfsmp3 cfsmp3 deleted the fix/issue-1576-legacy-single-dash-options branch December 20, 2025 09:32
@ccextractor-bot
Copy link
Collaborator

CCExtractor CI platform finished running the test files on windows. Below is a summary of the test results, when compared to test for commit a0593c6...:
Report Name Tests Passed
Broken 11/13
CEA-708 8/14
DVB 4/7
DVD 0/3
DVR-MS 2/2
General 11/27
Hardsubx 1/1
Hauppage 1/3
MP4 3/3
NoCC 10/10
Options 72/86
Teletext 7/21
WTV 12/13
XDS 30/34

Your PR breaks these cases:

NOTE: The following tests have been failing on the master branch as well as the PR:

Congratulations: Merging this PR would fix the following tests:

  • ccextractor --autoprogram --out=ttxt --latin1 --ucla --xds 8e8229b88b..., Last passed: Never
  • ccextractor --out=srt --latin1 611b4a9235..., Last passed: Never
  • ccextractor --autoprogram --out=ttxt --latin1 9a496d3828..., Last passed: Never
  • ccextractor --autoprogram --out=ttxt --latin1 c032183ef0..., Last passed: Never
  • ccextractor --autoprogram --out=ttxt --latin1 27e46255f0..., Last passed: Never
  • ccextractor --autoprogram --out=ttxt --latin1 132d7df7e9..., Last passed: Never
  • ccextractor --autoprogram --out=ttxt --latin1 99e5eaafdc..., Last passed: Never
  • ccextractor --autoprogram --out=ttxt --latin1 --ucla 5d3a29f9f8..., Last passed: Never
  • ccextractor --autoprogram --out=ttxt --latin1 --ucla 70000200c0..., Last passed: Never
  • ccextractor --autoprogram --out=ttxt --latin1 --ucla 15feae9133..., Last passed: Never
  • ccextractor --autoprogram --out=ttxt --latin1 --ucla 95dd33c6f1..., Last passed: Never
  • ccextractor --autoprogram --out=ttxt --latin1 --ucla --output-field 2 5d3a29f9f8..., Last passed: Never
  • ccextractor --hardsubx 1a0302f7fd..., Last passed: Never
  • ccextractor --autoprogram --out=ttxt --hauppauge --ucla --latin1 553d78e755..., Last passed: Never
  • ccextractor --out=dvdraw c83f765c66..., Last passed: Never
  • ccextractor --in=bin 988d4e8bba..., Last passed: Never
  • ccextractor --endcreditstext "CCextractor Ends crdit Testing" addf5e2fc9..., Last passed: Never
  • ccextractor --endcreditsforatleast 3 --endcreditstext "CCextractor Ends crdit Testing" addf5e2fc9..., Last passed: Never
  • ccextractor --endcreditsforatmost 2 --endcreditstext "CCextractor Ends crdit Testing" addf5e2fc9..., Last passed: Never
  • ccextractor --out=srt --latin1 f23a544ba8..., Last passed: Never
  • ccextractor --out=srt --latin1 97cc394d87..., Last passed: Never
  • ccextractor --out=srt --latin1 d7e7dbdf68..., Last passed: Never
  • ccextractor --out=srt --latin1 76734ac4a7..., Last passed: Never
  • ccextractor --out=srt --latin1 c791382c94..., Last passed: Never
  • ccextractor --out=srt --latin1 f673b2f916..., Last passed: Never
  • ccextractor --out=srt --latin1 da75bdee47..., Last passed: Never
  • ccextractor --out=srt --latin1 bd6f33a669..., Last passed: Never
  • ccextractor --out=srt --latin1 ae6327683e..., Last passed: Never
  • ccextractor --autoprogram --out=ttxt --latin1 --ucla --xds 725a49f871..., Last passed: Never
  • ccextractor --autoprogram --out=ttxt --xds --latin1 --ucla e274a73653..., Last passed: Never
  • ccextractor --autoprogram --out=ttxt --xds --latin1 --ucla 85058ad37e..., Last passed: Never
  • ccextractor --autoprogram --out=ttxt --latin1 --ucla --xds b22260d065..., Last passed: Never
  • ccextractor --autoprogram --out=ttxt --latin1 --xds --ucla c813e713a0..., Last passed: Never
  • ccextractor --autoprogram --out=ttxt --latin1 --ucla --xds 27fab4dbb6..., Last passed: Never
  • ccextractor --autoprogram --out=ttxt --latin1 --ucla --xds bbd5bb52fc..., Last passed: Never
  • ccextractor --autoprogram --out=ttxt --latin1 --ucla --xds b992e0cccb..., Last passed: Never
  • ccextractor --autoprogram --out=ttxt --latin1 --ucla --xds d0291cdcf6..., Last passed: Never
  • ccextractor --autoprogram --out=ttxt --latin1 --ucla 7d2730d38e..., Last passed: Never
  • ccextractor --autoprogram --out=ttxt --latin1 --ucla --xds 53339f3455..., Last passed: Never
  • ccextractor --autoprogram --out=ttxt --latin1 --ucla --xds 83b03036a2..., Last passed: Never
  • ccextractor --autoprogram --out=ttxt --latin1 --ucla --xds 7d3f25c32c..., Last passed: Never
  • ccextractor --autoprogram --out=ttxt --latin1 --ucla --xds f41d4c29a1..., Last passed: Never
  • ccextractor --autoprogram --out=ttxt --latin1 --ucla --xds 88cd42b89a..., Last passed: Never
  • ccextractor --autoprogram --out=ttxt --latin1 --ucla --xds 7f41299cc7..., Last passed: Never
  • ccextractor --autoprogram --out=ttxt --latin1 --ucla --xds 0069dffd21..., Last passed: Never

It seems that not all tests were passed completely. This is an indication that the output of some files is not as expected (but might be according to you).

Check the result page for more info.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Issue 1077 Still lives

2 participants