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