Skip to content

Commit

Permalink
bump mml-lib@v0.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
soywod committed Sep 25, 2023
1 parent fc79752 commit 3d1789d
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 17 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Changed

- Bumped `mml-lib@v0.5.0`.

## [0.3.0] - 2023-09-20

### Added

- Added better diagnostic with `ariadne`.
Expand Down
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 8 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,13 @@ name = "mml"
path = "src/main.rs"

[features]
all = ["compiler", "interpreter", "pgp-commands", "pgp-gpg", "pgp-native"]
default = ["compiler", "interpreter"]
default = [
"compiler",
"interpreter",
# "pgp-commands",
# "pgp-gpg",
# "pgp-native",
]
compiler = ["mml-lib/compiler", "ariadne"]
interpreter = ["mml-lib/interpreter"]
pgp-commands = ["mml-lib/pgp-commands"]
Expand Down Expand Up @@ -59,7 +64,7 @@ version = "0.10"
version = "0.4"

[dependencies.mml-lib]
version = "=0.4.0"
version = "=0.5.0"
default-features = false

[dependencies.shellexpand-utils]
Expand Down
17 changes: 9 additions & 8 deletions src/mml/compiler/handlers.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
use anyhow::{Context, Result};
use ariadne::{Color, Label, Report, ReportKind, Source};
use mml::{message::body::compiler::Error as CompileMmlBodyError, Error, MmlCompiler};
use mml::{message::body::compiler::Error as CompileMmlBodyError, Error, MmlCompilerBuilder};

pub async fn compile(mml: String) -> Result<()> {
let compiler = MmlCompiler::new();
let compiler = MmlCompilerBuilder::new()
// TODO:
// .with_pgp(…)
.build(&mml)
.context("cannot build MML compiler")?;

// TODO: add PGP args?
// compiler = compiler.with_pgp(…)

match compiler.compile(&mml).await {
match compiler.compile().await {
Err(Error::CompileMmlBodyError(CompileMmlBodyError::ParseMmlError(errs, body))) => {
errs.into_iter().for_each(|err| {
Report::build(ReportKind::Error, (), err.span().start)
Expand All @@ -25,8 +26,8 @@ pub async fn compile(mml: String) -> Result<()> {
Ok(())
}
Err(err) => Err(err).context("cannot compile MML message"),
Ok(mime) => {
let mime = mime.write_to_string()?;
Ok(res) => {
let mime = res.into_string()?;
print!("{mime}");
Ok(())
}
Expand Down
9 changes: 5 additions & 4 deletions src/mml/interpreter/handlers.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use anyhow::{Context, Result};
use mml::{
message::{FilterHeaders, FilterParts},
MimeInterpreter,
MimeInterpreterBuilder,
};
use std::path::PathBuf;

Expand All @@ -16,7 +16,7 @@ pub async fn interpret(
show_plain_texts_signature: bool,
mime: String,
) -> Result<()> {
let interpreter = MimeInterpreter::new()
let interpreter = MimeInterpreterBuilder::new()
// TODO:
// .with_pgp(…)
.with_show_headers(filter_headers)
Expand All @@ -28,10 +28,11 @@ pub async fn interpret(
.with_save_some_attachments_dir(save_attachments_dir)
.with_show_attachments(show_attachments)
.with_show_inline_attachments(show_inline_attachments)
.with_show_plain_texts_signature(show_plain_texts_signature);
.with_show_plain_texts_signature(show_plain_texts_signature)
.build();

let mml = interpreter
.interpret_bytes(mime.as_bytes())
.from_bytes(mime.as_bytes())
.await
.context("cannot interpreter MIME message")?;

Expand Down

0 comments on commit 3d1789d

Please sign in to comment.