Upgrade snafu to 0.7.x
This commit is contained in:
15
Cargo.lock
generated
15
Cargo.lock
generated
@@ -189,6 +189,12 @@ version = "0.12.3"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
|
checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "heck"
|
||||||
|
version = "0.4.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hermit-abi"
|
name = "hermit-abi"
|
||||||
version = "0.1.19"
|
version = "0.1.19"
|
||||||
@@ -514,9 +520,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "snafu"
|
name = "snafu"
|
||||||
version = "0.6.10"
|
version = "0.7.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "eab12d3c261b2308b0d80c26fffb58d17eba81a4be97890101f416b478c79ca7"
|
checksum = "a152ba99b054b22972ee794cf04e5ef572da1229e33b65f3c57abbff0525a454"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"doc-comment",
|
"doc-comment",
|
||||||
"snafu-derive",
|
"snafu-derive",
|
||||||
@@ -524,10 +530,11 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "snafu-derive"
|
name = "snafu-derive"
|
||||||
version = "0.6.10"
|
version = "0.7.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1508efa03c362e23817f96cde18abed596a25219a8b2c66e8db33c03543d315b"
|
checksum = "d5e79cdebbabaebb06a9bdbaedc7f159b410461f63611d4d0e3fb0fab8fed850"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"heck",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn",
|
"syn",
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ rayon = "1.5.3"
|
|||||||
regex = "1.6.0"
|
regex = "1.6.0"
|
||||||
serde_yaml = "0.9.14"
|
serde_yaml = "0.9.14"
|
||||||
slug = "0.1.4"
|
slug = "0.1.4"
|
||||||
snafu = "0.6.10"
|
snafu = "0.7.3"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
pretty_assertions = "1.3.0"
|
pretty_assertions = "1.3.0"
|
||||||
|
|||||||
16
src/lib.rs
16
src/lib.rs
@@ -391,7 +391,7 @@ impl<'a> Exporter<'a> {
|
|||||||
true => self.parse_and_export_obsidian_note(src, dest),
|
true => self.parse_and_export_obsidian_note(src, dest),
|
||||||
false => copy_file(src, dest),
|
false => copy_file(src, dest),
|
||||||
}
|
}
|
||||||
.context(FileExportError { path: src })
|
.context(FileExportSnafu { path: src })
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_and_export_obsidian_note(&self, src: &Path, dest: &Path) -> Result<()> {
|
fn parse_and_export_obsidian_note(&self, src: &Path, dest: &Path) -> Result<()> {
|
||||||
@@ -416,15 +416,15 @@ impl<'a> Exporter<'a> {
|
|||||||
};
|
};
|
||||||
if write_frontmatter {
|
if write_frontmatter {
|
||||||
let mut frontmatter_str = frontmatter_to_str(context.frontmatter)
|
let mut frontmatter_str = frontmatter_to_str(context.frontmatter)
|
||||||
.context(FrontMatterEncodeError { path: src })?;
|
.context(FrontMatterEncodeSnafu { path: src })?;
|
||||||
frontmatter_str.push('\n');
|
frontmatter_str.push('\n');
|
||||||
outfile
|
outfile
|
||||||
.write_all(frontmatter_str.as_bytes())
|
.write_all(frontmatter_str.as_bytes())
|
||||||
.context(WriteError { path: &dest })?;
|
.context(WriteSnafu { path: &dest })?;
|
||||||
}
|
}
|
||||||
outfile
|
outfile
|
||||||
.write_all(render_mdevents_to_mdtext(markdown_events).as_bytes())
|
.write_all(render_mdevents_to_mdtext(markdown_events).as_bytes())
|
||||||
.context(WriteError { path: &dest })?;
|
.context(WriteSnafu { path: &dest })?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -438,11 +438,11 @@ impl<'a> Exporter<'a> {
|
|||||||
file_tree: context.file_tree(),
|
file_tree: context.file_tree(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
let content = fs::read_to_string(&path).context(ReadError { path })?;
|
let content = fs::read_to_string(&path).context(ReadSnafu { path })?;
|
||||||
let (frontmatter, content) =
|
let (frontmatter, content) =
|
||||||
matter::matter(&content).unwrap_or(("".to_string(), content.to_string()));
|
matter::matter(&content).unwrap_or(("".to_string(), content.to_string()));
|
||||||
let frontmatter =
|
let frontmatter =
|
||||||
frontmatter_from_str(&frontmatter).context(FrontMatterDecodeError { path })?;
|
frontmatter_from_str(&frontmatter).context(FrontMatterDecodeSnafu { path })?;
|
||||||
|
|
||||||
let mut parser_options = Options::empty();
|
let mut parser_options = Options::empty();
|
||||||
parser_options.insert(Options::ENABLE_TABLES);
|
parser_options.insert(Options::ENABLE_TABLES);
|
||||||
@@ -746,7 +746,7 @@ fn create_file(dest: &Path) -> Result<File> {
|
|||||||
}
|
}
|
||||||
File::create(&dest)
|
File::create(&dest)
|
||||||
})
|
})
|
||||||
.context(WriteError { path: dest })?;
|
.context(WriteSnafu { path: dest })?;
|
||||||
Ok(file)
|
Ok(file)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -759,7 +759,7 @@ fn copy_file(src: &Path, dest: &Path) -> Result<()> {
|
|||||||
}
|
}
|
||||||
std::fs::copy(&src, &dest)
|
std::fs::copy(&src, &dest)
|
||||||
})
|
})
|
||||||
.context(WriteError { path: dest })?;
|
.context(WriteSnafu { path: dest })?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
use crate::{ExportError, WalkDirError};
|
use crate::{ExportError, WalkDirSnafu};
|
||||||
use ignore::{DirEntry, Walk, WalkBuilder};
|
use ignore::{DirEntry, Walk, WalkBuilder};
|
||||||
use snafu::ResultExt;
|
use snafu::ResultExt;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
@@ -88,9 +88,9 @@ pub fn vault_contents(path: &Path, opts: WalkOptions) -> Result<Vec<PathBuf>> {
|
|||||||
let mut contents = Vec::new();
|
let mut contents = Vec::new();
|
||||||
let walker = opts.build_walker(path);
|
let walker = opts.build_walker(path);
|
||||||
for entry in walker {
|
for entry in walker {
|
||||||
let entry = entry.context(WalkDirError { path })?;
|
let entry = entry.context(WalkDirSnafu { path })?;
|
||||||
let path = entry.path();
|
let path = entry.path();
|
||||||
let metadata = entry.metadata().context(WalkDirError { path })?;
|
let metadata = entry.metadata().context(WalkDirSnafu { path })?;
|
||||||
|
|
||||||
if metadata.is_dir() {
|
if metadata.is_dir() {
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
Reference in New Issue
Block a user