diff options
Diffstat (limited to 'src/bin/cli/mod.rs')
-rw-r--r-- | src/bin/cli/mod.rs | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/bin/cli/mod.rs b/src/bin/cli/mod.rs index 1bb5ea3..855a066 100644 --- a/src/bin/cli/mod.rs +++ b/src/bin/cli/mod.rs @@ -1,7 +1,9 @@ //! CLI Functionality abstractions +#![allow(unused)] + use anyhow::Result; -use subplot::{Document, Style}; +use subplot::{DataFile, Document, Style, SubplotError}; use std::path::Path; @@ -12,3 +14,12 @@ pub fn load_document<P: AsRef<Path>>(filename: P, style: Style) -> Result<Docume Ok(doc) } + +pub fn extract_file<'a>(doc: &'a Document, filename: &str) -> Result<&'a DataFile> { + for file in doc.files() { + if file.filename() == filename { + return Ok(file); + } + } + Err(SubplotError::EmbeddedFileNotFound(filename.to_owned()).into()) +} |