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