Fix format flag crash and add comprehensive tests

- Remove NoOptDefVal which caused the format flag to fail with space-separated values
- Add 5 comprehensive unit tests for format flag: space syntax, short form, equals syntax, default value, and case-insensitive
- Update README with detailed format flag documentation and examples
- Format flag now works with all syntaxes: --format webp, -f webp, --format=webp
- Default value (webp) is preserved and shown in help text

Co-authored-by: Belphemur <197810+Belphemur@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2025-12-10 20:19:10 +00:00
parent 1fa54e1936
commit a2feca6cca
4 changed files with 259 additions and 6 deletions

View File

@@ -42,6 +42,22 @@ Optimize all CBZ/CBR files in a folder recursively:
cbzconverter optimize [folder] --quality 85 --parallelism 2 --override --format webp --split
```
The format flag can be specified in multiple ways:
```sh
# Using space-separated syntax
cbzconverter optimize [folder] --format webp
# Using short form with space
cbzconverter optimize [folder] -f webp
# Using equals syntax
cbzconverter optimize [folder] --format=webp
# Format is case-insensitive
cbzconverter optimize [folder] --format WEBP
```
With timeout to avoid hanging on problematic chapters:
```sh
@@ -74,7 +90,9 @@ docker run -v /path/to/comics:/comics ghcr.io/belphemur/cbzoptimizer:latest watc
- `--parallelism`, `-n`: Number of chapters to convert in parallel. Default is 2.
- `--override`, `-o`: Override the original files. For CBZ files, overwrites the original. For CBR files, deletes the original CBR and creates a new CBZ. Default is false.
- `--split`, `-s`: Split long pages into smaller chunks. Default is false.
- `--format`, `-f`: Format to convert the images to (e.g., webp). Default is webp.
- `--format`, `-f`: Format to convert the images to (currently supports: webp). Default is webp.
- Can be specified as: `--format webp`, `-f webp`, or `--format=webp`
- Case-insensitive: `webp`, `WEBP`, and `WebP` are all valid
- `--timeout`, `-t`: Maximum time allowed for converting a single chapter (e.g., 30s, 5m, 1h). 0 means no timeout. Default is 0.
- `--log`, `-l`: Set log level; can be 'panic', 'fatal', 'error', 'warn', 'info', 'debug', or 'trace'. Default is info.