/// Parses the contents of a collection file into a Collection struct.
use std::path::Path;

use pest_derive::Parser;

mod collection;
pub mod context;
mod declarations;
mod legacy_header;
mod preprocessor;
mod protocol;
mod request;
mod spans;
mod syntax;
mod variables;

pub use collection::parse_collection;
pub use syntax::{
    SyntaxRequestSummary, SyntaxSummary, inspect_collection_syntax,
};
pub use variables::eval_shell_script;

#[derive(Parser)]
#[grammar = "src/parser/grammar.pest"]
struct CollectionParser;

pub fn preprocess_only(input: &str, working_dir: &Path) -> Result<String, String> {
    preprocessor::preprocess(input, working_dir).map_err(|err| err.to_string())
}

#[cfg(test)]
mod tests;