1use crate::{ConfigureState, ExtFile, ExtStr};2use clap::Clap;3use jrsonnet_evaluator::{error::Result, EvaluationState};45#[derive(Clap)]6#[clap(help_heading = "TOP LEVEL ARGUMENTS")]7pub struct TLAOpts {8 9 10 11 12 #[clap(13 long,14 short = 'A',15 name = "name[=tla data]",16 number_of_values = 1,17 multiple_occurrences = true18 )]19 tla_str: Vec<ExtStr>,20 21 22 #[clap(23 long,24 name = "name=tla path",25 number_of_values = 1,26 multiple_occurrences = true27 )]28 tla_str_file: Vec<ExtFile>,29 30 31 #[clap(32 long,33 name = "name[=tla source]",34 number_of_values = 1,35 multiple_occurrences = true36 )]37 tla_code: Vec<ExtStr>,38 39 40 #[clap(41 long,42 name = "name=tla code path",43 number_of_values = 1,44 multiple_occurrences = true45 )]46 tla_code_file: Vec<ExtFile>,47}48impl ConfigureState for TLAOpts {49 fn configure(&self, state: &EvaluationState) -> Result<()> {50 for tla in self.tla_str.iter() {51 state.add_tla_str((&tla.name as &str).into(), (&tla.value as &str).into());52 }53 for tla in self.tla_str_file.iter() {54 state.add_tla_str((&tla.name as &str).into(), (&tla.value as &str).into())55 }56 for tla in self.tla_code.iter() {57 state.add_tla_code((&tla.name as &str).into(), (&tla.value as &str).into())?;58 }59 for tla in self.tla_code_file.iter() {60 state.add_tla_code((&tla.name as &str).into(), (&tla.value as &str).into())?;61 }62 Ok(())63 }64}