uchicago-library / attachment-converter

Attachment Converter: tool for batch converting attachments in an email mailbox
GNU General Public License v2.0
8 stars 3 forks source link

Only print Skeleton if there are attachments to convert #92

Closed nmmull closed 5 months ago

nmmull commented 6 months ago

The progress bar should now only print the skeleton of an email if there are attachments to convert. It will also list the conversions it is going to do.

On an email with conversions:

$ dune exec -- ./main.exe < test2.eml > out.eml 
Parsing email...                    
Processing email with structure...
=================================
Multipart
|-- Multipart
|   |-- Body
|   |-- Body
|-- Attachment: online_cap_tapev2.pdf
=================================
Conversions to perform...
=================================
online_cap_tapev2.pdf to application/pdf (soffice-pdf-to-pdf)
online_cap_tapev2.pdf to text/plain (pdftotext-pdf-to-txt)
=================================
Converting online_cap_tapev2.pdf to online_cap_tapev2_CONVERTED1709333305.pdf (PDF-A)...
Converting online_cap_tapev2.pdf to online_cap_tapev2_CONVERTED1709333315.txt...
Email now has structure...
=================================
Multipart
|-- Multipart
|   |-- Body
|   |-- Body
|-- Attachment: online_cap_tapev2.pdf
|-- CONVERTED Attachment: online_cap_tapev2_CONVERTED1709333305.pdf
|-- CONVERTED Attachment: online_cap_tapev2_CONVERTED1709333315.txt
=================================
Processing complete.

And then running again on the output (with idempotence)

$ dune exec -- ./main.exe < out.eml > out2.eml
Parsing email...                   
Nothing to convert...
Processing complete.

I also fixed a bug in which quotes around filenames were being dropped. We will have to make clear in the documentation that Parameter.value returns an unquoted value by default.