mdvault_core/scripting/
hooks.rs1use std::path::PathBuf;
7
8use thiserror::Error;
9
10#[derive(Debug, Clone)]
14pub struct NoteContext {
15 pub path: PathBuf,
17 pub note_type: String,
19 pub frontmatter: serde_yaml::Value,
21 pub content: String,
23 pub variables: serde_yaml::Value,
25}
26
27impl NoteContext {
28 pub fn new(
30 path: PathBuf,
31 note_type: String,
32 frontmatter: serde_yaml::Value,
33 content: String,
34 variables: serde_yaml::Value,
35 ) -> Self {
36 Self { path, note_type, frontmatter, content, variables }
37 }
38}
39
40#[derive(Debug, Error)]
42pub enum HookError {
43 #[error("template not found: {0}")]
45 TemplateNotFound(String),
46
47 #[error("capture not found: {0}")]
49 CaptureNotFound(String),
50
51 #[error("macro not found: {0}")]
53 MacroNotFound(String),
54
55 #[error("hook execution failed: {0}")]
57 Execution(String),
58
59 #[error("Lua error: {0}")]
61 LuaError(String),
62
63 #[error("template render error: {0}")]
65 TemplateRender(String),
66
67 #[error("capture execution error: {0}")]
69 CaptureExecution(String),
70
71 #[error("macro execution error: {0}")]
73 MacroExecution(String),
74
75 #[error("IO error: {0}")]
77 Io(#[from] std::io::Error),
78}