difftreelog
docs fix CLI's `lib.rs`
in: master
1 file changed
crates/jrsonnet-cli/src/lib.rsdiffbeforeafterboth1mod ext;2mod manifest;3mod tla;4mod trace;56pub use ext::*;7pub use manifest::*;8pub use tla::*;9pub use trace::*;1011use clap::Clap;12use jrsonnet_evaluator::{error::Result, EvaluationState, FileImportResolver};13use std::path::PathBuf;1415pub trait ConfigureState {16 fn configure(&self, state: &EvaluationState) -> Result<()>;17}1819#[derive(Clap)]20// #[clap(help_heading = "INPUT")]21pub struct InputOpts {22 #[clap(23 long,24 short = 'e',25 about = "Threat input as code, evaluate them instead of reading file"26 )]27 pub evaluate: bool,2829 #[clap(about = "File to compile (Or code directly, if --evaluate is specified)")]30 pub input: String,31}3233#[derive(Clap)]34// #[clap(help_heading = "OPTIONS")]35pub struct MiscOpts {36 /// Disable standard library. By default, standard library will be available via global `std` variable.37 /// Beware that standard library will still be loaded if choosen manifestification method is not `none`38 #[clap(long)]39 no_stdlib: bool,4041 /// Number of allowed stack frames, stack overflow error will be returned if reached42 #[clap(long, short = 's', default_value = "200")]43 max_stack: usize,4445 /// Library search dirs. Any not found `imported` file will be searched in them.46 /// Can also be specified via JSONNET_PATH, which should contain colon (semicolon on Windows) delimited list of directories47 #[clap(long, short = 'J')]48 jpath: Vec<PathBuf>,49}50impl ConfigureState for MiscOpts {51 fn configure(&self, state: &EvaluationState) -> Result<()> {52 if !self.no_stdlib {53 state.with_stdlib();54 }5556 state.set_import_resolver(Box::new(FileImportResolver {57 library_paths: self.jpath.clone(),58 }));5960 state.set_max_stack(self.max_stack);61 Ok(())62 }63}6465/// For general configuration of jsonnet66#[derive(Clap)]67#[clap(name = "jrsonnet", version, author)]68pub struct GeneralOpts {69 #[clap(flatten)]70 misc: MiscOpts,7172 #[clap(flatten)]73 tla: TLAOpts,74 #[clap(flatten)]75 ext: ExtVarOpts,7677 #[clap(flatten)]78 trace: TraceOpts,79}8081impl ConfigureState for GeneralOpts {82 fn configure(&self, state: &EvaluationState) -> Result<()> {83 // Configure trace first, because tla-code/ext-code can throw84 self.trace.configure(state)?;85 self.misc.configure(state)?;86 self.tla.configure(state)?;87 self.ext.configure(state)?;88 Ok(())89 }90}