MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / parse_env_pairs

Function parse_env_pairs

crates/openshell-cli/src/run.rs:3993–4008  ·  view source on GitHub ↗
(items: &[String])

Source from the content-addressed store, hash-verified

3991}
3992
3993pub fn parse_env_pairs(items: &[String]) -> Result<HashMap<String, String>> {
3994 let map = parse_key_value_pairs(items, "--env")?;
3995 for key in map.keys() {
3996 if !is_valid_env_name(key) {
3997 return Err(miette::miette!(
3998 "--env key must match [A-Za-z_][A-Za-z0-9_]*; got '{key}'"
3999 ));
4000 }
4001 if key.starts_with("OPENSHELL_") {
4002 return Err(miette::miette!(
4003 "--env keys starting with OPENSHELL_ are reserved; got '{key}'"
4004 ));
4005 }
4006 }
4007 Ok(map)
4008}
4009
4010fn is_valid_env_name(key: &str) -> bool {
4011 let mut bytes = key.bytes();

Calls 2

parse_key_value_pairsFunction · 0.85
is_valid_env_nameFunction · 0.85