execute_evcxr/
lib.rs

1#![doc = include_str!("../README.md")]
2
3pub(crate) mod binary_crate;
4mod evcxr_source;
5pub(crate) mod parsed_evcxr;
6mod scriptlike_rust;
7mod config;
8
9pub(crate) use binary_crate::BinaryCrate;
10pub(crate) use evcxr_source::EvcxrSource;
11use parsed_evcxr::ParsedEvcxr;
12pub(crate) use scriptlike_rust::ScriptlikeRust;
13pub use config::Config;
14
15pub fn execute_evcxr<C,S>(source: S, config: C)
16where
17    S: AsRef<str>,
18    C: AsRef<Config>,
19{
20    let src = EvcxrSource::from(source);
21    let parsed_evcxr = match src.parse() {
22        Ok(parsed) => parsed,
23        Err(e) => {
24            eprintln!("{:?}", e);
25            eprintln!("start: {:?}; end: {:?}", e.span().start(), e.span().end());
26            return;
27        }
28    };
29    match parsed_evcxr.execute_via_binary_crate(config.as_ref()) {
30        Ok(_) => (),
31        Err(e) => {
32            eprintln!("{:?}", e);
33        }
34    };
35}