aboutsummaryrefslogtreecommitdiffstats
path: root/src
AgeCommit message (Collapse)Author
2021-03-20main(): Add a version command line argumentTeddy Wing
Make it easy to find out what version of the program is installed.
2021-03-16Set `$attribution_locale` in generated muttrcTeddy Wing
The French attribution from before capitalised the month name because I have an EN locale by default. The month shouldn't be capitalised in French. Set the `$attribution_locale` to match the language of the attribution template string. Hard-coding `en_US` on the English one as that's the locale I'm used to.
2021-03-14Remove TODOs and debug output from multipart and HTML workTeddy Wing
Now that we've handled 'multipart/relative' and HTML-only 'text/plain'-less emails, we can remove these.
2021-03-14Extract HTML tag remover to a functionTeddy Wing
Now that we're using it in two places, move it to a function. Also remove the `unwrap` call.
2021-03-14Extract email body from HTML part if no text part existsTeddy Wing
We're already doing this for single-part emails. This change makes it work additionally for multipart emails.
2021-03-14get_email_body(): Remove unnecessary loops over headersTeddy Wing
Now that I know the `Content-Type` header is already parsed in the original email parse call, use that instead of looping over the headers trying to find the content type.
2021-03-14Strip HTML tags from single-part HTML emailsTeddy Wing
When an HTML body is fed to 'whatlang', it recognises it as English. This is likely due to the English HTML syntax. Remove all HTML tags with a simple regex substitution to get the language recognition working more properly. This doesn't remove CSS, which could also confuse the language recogniser. In a limited test, it seemed to work without having to remove any CSS, so not bothering with that. Still need to get this working for multipart emails.
2021-03-14Debug email content typesTeddy Wing
Figuring out the different content types and subparts for different kinds of emails.
2021-03-14get_email_body(): Add TODOsTeddy Wing
2021-03-14get_email_body(): Support emails with attachmentsTeddy Wing
Parse the text email body out of `multipart/alternative` parts.
2021-03-14Import `thiserror::Error` as `Error`Teddy Wing
Now that we're no longer using `anyhow::Error` as `Error`.
2021-03-14main: Collapse `match`Teddy Wing
Collapse arms that return the same exit code.
2021-03-14Add additional sysexits error codes for other errorsTeddy Wing
Give types to the errors in `run()` and exit with appropriate error codes. Split out an additional error type so we can wrap errors from the non-main functions. Remove 'anyhow', replacing it with 'thiserror' now that we're using error types.
2021-03-14Exit with sysexits.h error codes on errorTeddy Wing
2021-03-14Wrap errors in a custom `OttolangyError` typeTeddy Wing
Give us a way to match on the type of error so we can return an appropriate exit code.
2021-03-14Add license (GNU GPLv3+)Teddy Wing
2021-03-13Add context to errorsTeddy Wing
Include the 'anyhow' crate to add additional context to errors.
2021-03-13Add documentationTeddy Wing
2021-03-13get_email_body(): Add a real error stringTeddy Wing
Replace the temporary error string with one that provides a hair more context.
2021-03-13get_email_body(): Remove unnecessary `else` branchTeddy Wing
2021-03-13Remove debug print callsTeddy Wing
These print outputs were for help developing and debugging. They're no longer necessary since the program is basically working.
2021-03-13main(): Replace `unwrap`s with tryTeddy Wing
Move the `main()` function contents to a new `run()` function that returns a `Result`. This way we can easily print the error in `main()`.
2021-03-13Replace `unwrap`s with try in non-main functionsTeddy Wing
2021-03-13Write an attribution config fileTeddy Wing
Set attribution config strings for French and English. If the input email's body language is in French, set my French attribution string. Otherwise use English. Write the attribution string to a config file at `~/.local/share/ottolangy/attribution.muttrc`. We can then source this config file to set the attribution.
2021-03-09Use 'whatlang' to detect the language of the email bodyTeddy Wing
2021-03-09Move email body parsing code to a new functionTeddy Wing
Isolate this block.
2021-03-09Fix single-part email handlingTeddy Wing
The old code was from when I was testing with a multipart email and hadn't figured out how to extract the body from it.
2021-03-09Remove old email parsing trialsTeddy Wing
Now that we've worked out how to do this, I can remove my old essays.
2021-03-09Work out how to get the body of a multipart emailTeddy Wing
Figured out why I was getting an empty string before: I was inputting a multipart email. I need to actually look through each part to get the message body. Look for the body of the "text/plain" part.
2021-03-09Testing out different libraries for email parsingTeddy Wing
2021-03-08New Rust v1.50.0 projectTeddy Wing
Generated with: $ cargo init --bin