diff --git a/src/files/commands.rs b/src/files/commands.rs index f5be0a0..42ac4a1 100644 --- a/src/files/commands.rs +++ b/src/files/commands.rs @@ -424,6 +424,7 @@ pub enum Command { #[derive(Debug)] pub struct File { + pub contents: String, pub includes: Vec, pub timezone: Option, pub commands: Vec, diff --git a/src/files/parse.rs b/src/files/parse.rs index ead0bb5..200ebf9 100644 --- a/src/files/parse.rs +++ b/src/files/parse.rs @@ -759,10 +759,11 @@ fn parse_command(p: Pair<'_, Rule>, file: &mut File) -> Result<()> { Ok(()) } -pub fn parse_file(p: Pair<'_, Rule>) -> Result { +pub fn parse_file(p: Pair<'_, Rule>, contents: String) -> Result { assert_eq!(p.as_rule(), Rule::file); let mut file = File { + contents, includes: vec![], timezone: None, commands: vec![], @@ -787,5 +788,5 @@ pub fn parse(path: &Path, input: &str) -> Result { let file_pair = pairs.next().unwrap(); assert_eq!(pairs.next(), None); - parse_file(file_pair).map_err(|e| e.with_path(&pathstr)) + parse_file(file_pair, input.to_string()).map_err(|e| e.with_path(&pathstr)) }