Support ENV variables in CD names

This commit is contained in:
Jaby
2024-03-21 16:51:17 -05:00
parent cb6dbbb346
commit f865be0c7c
4 changed files with 13 additions and 4 deletions

View File

@@ -38,6 +38,8 @@ macro_rules! format_if_error_drop_cause {
};
}
const DEFAULT_ENV_EXPAND_OPTIONS : ExpandOptions = ExpandOptions{expansion_type: Some(ExpansionType::All), default_to_empty: false};
pub struct Error {
pub exit_code: i32,
pub text: String,
@@ -162,8 +164,12 @@ pub fn callback_if_any_error<F: Fn(String) -> String, T, E: std::string::ToStrin
}
}
pub fn string_with_env_from(str: &str) -> String {
String::from(envmnt::expand(str, Some(DEFAULT_ENV_EXPAND_OPTIONS)))
}
pub fn path_with_env_from(path: &str) -> PathBuf {
PathBuf::from(envmnt::expand(path, Some(ExpandOptions{expansion_type: Some(ExpansionType::All), default_to_empty: false})))
PathBuf::from(envmnt::expand(path, Some(DEFAULT_ENV_EXPAND_OPTIONS)))
}
pub fn open_output_file(output_path: &PathBuf) -> Result<BufWriter<std::fs::File>, Error> {