1use clap::Parser;2use jrsonnet_evaluator::{3 IStr, error::Result, gc::WithCapacityExt as _, rustc_hash::FxHashMap, tla::TlaArg,4};56use crate::{ExtFile, ExtStr};78#[derive(Parser)]9#[clap(next_help_heading = "TOP LEVEL ARGUMENTS")]10#[allow(clippy::struct_field_names)]11pub struct TlaOpts {12 13 14 15 16 #[clap(long, short = 'A', name = "name[=tla data]", number_of_values = 1)]17 tla_str: Vec<ExtStr>,18 19 20 #[clap(long, name = "name=tla path", number_of_values = 1)]21 tla_str_file: Vec<ExtFile>,22 23 24 #[clap(long, name = "name[=tla source]", number_of_values = 1)]25 tla_code: Vec<ExtStr>,26 27 28 #[clap(long, name = "name=tla code path", number_of_values = 1)]29 tla_code_file: Vec<ExtFile>,30}31impl TlaOpts {32 pub fn tla_opts(&self) -> Result<FxHashMap<IStr, TlaArg>> {33 let mut out = FxHashMap::new();34 for ext in &self.tla_str {35 out.insert(36 ext.name.as_str().into(),37 TlaArg::String(ext.value.as_str().into()),38 );39 }40 for ext in &self.tla_str_file {41 out.insert(42 ext.name.as_str().into(),43 TlaArg::ImportStr(ext.name.as_str().into()),44 );45 }46 for ext in &self.tla_code {47 out.insert(48 ext.name.as_str().into(),49 TlaArg::InlineCode(ext.value.clone()),50 );51 }52 for ext in &self.tla_code_file {53 out.insert(ext.name.as_str().into(), TlaArg::Import(ext.path.clone()));54 }55 Ok(out)56 }57}