From eae62ba0f199ffdf7bbe2f07eb320723355de732 Mon Sep 17 00:00:00 2001 From: Ethan Kinnear <51250849+superatomic@users.noreply.github.com> Date: Sat, 23 Apr 2022 23:22:37 -0500 Subject: [PATCH] Allow for setting (but not unsetting!) variables As described in #31. This commit is feature incomplete. --- src/config_file.rs | 1 + src/main.rs | 2 ++ 2 files changed, 3 insertions(+) diff --git a/src/config_file.rs b/src/config_file.rs index 014d6cb..7475f1b 100644 --- a/src/config_file.rs +++ b/src/config_file.rs @@ -49,6 +49,7 @@ pub(crate) enum EnvVariableOption { pub(crate) enum EnvVariableValue { String(String), Array(Vec), + Set(bool), } #[cfg(test)] diff --git a/src/main.rs b/src/main.rs index 4064b84..f48ac69 100644 --- a/src/main.rs +++ b/src/main.rs @@ -233,6 +233,8 @@ fn to_shell_source(vars: &EnvironmentVariables, shell: &Shell) -> String { // Any arrays are treated as a path. let (value, is_path) = match raw_value { EnvVariableValue::String(string) => (expand_value(string.as_str()), false), + EnvVariableValue::Set(true) => ("1".to_string(), false), + EnvVariableValue::Set(false) => continue, // todo! EnvVariableValue::Array(array) => { let v_expanded: Vec = array.iter().map(|value| expand_value(value)).collect();