difftreelog
feat read paths from JSONNET_PATH env
in: master
1 file changed
crates/jrsonnet-cli/src/lib.rsdiffbeforeafterboth101011use clap::Clap;11use clap::Clap;12use jrsonnet_evaluator::{error::Result, EvaluationState, FileImportResolver};12use jrsonnet_evaluator::{error::Result, EvaluationState, FileImportResolver};13use std::path::PathBuf;13use std::{env, path::PathBuf};141415pub trait ConfigureState {15pub trait ConfigureState {16 fn configure(&self, state: &EvaluationState) -> Result<()>;16 fn configure(&self, state: &EvaluationState) -> Result<()>;47 #[clap(long, short = 's', default_value = "200")]47 #[clap(long, short = 's', default_value = "200")]48 max_stack: usize,48 max_stack: usize,494950 /// Library search dirs.50 /// Library search dirs. (right-most wins)51 /// Any not found `imported` file will be searched in these.51 /// Any not found `imported` file will be searched in these.52 /// This can also be specified via `JSONNET_PATH` variable,52 /// This can also be specified via `JSONNET_PATH` variable,53 /// which should contain a colon-separated (semicolon-separated on Windows) list of directories.53 /// which should contain a colon-separated (semicolon-separated on Windows) list of directories.60 state.with_stdlib();60 state.with_stdlib();61 }61 }6263 let mut library_paths = self.jpath.clone();64 library_paths.reverse();65 if let Some(path) = env::var_os("JSONNET_PATH") {66 library_paths.extend(env::split_paths(path.as_os_str()));67 }626863 state.set_import_resolver(Box::new(FileImportResolver {69 state.set_import_resolver(Box::new(FileImportResolver { library_paths }));64 library_paths: self.jpath.clone(),65 }));667067 state.set_max_stack(self.max_stack);71 state.set_max_stack(self.max_stack);