//! CLI Functionality abstractions #![allow(unused)] use anyhow::Result; use subplot::{DataFile, Document, Style, SubplotError}; use std::path::Path; pub fn load_document>(filename: P, style: Style) -> Result { let filename = filename.as_ref(); let base_path = subplot::get_basedir_from(filename)?; let doc = Document::from_file(&base_path, filename, style)?; 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()) }