Skip to content

Commit

Permalink
Parse conda env_names and env_paths from config
Browse files Browse the repository at this point in the history
  • Loading branch information
maxkapur committed Feb 21, 2025
1 parent bd7358e commit 097063f
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,16 @@ pub struct Python {
poetry_force_self_update: Option<bool>,
}

#[derive(Deserialize, Default, Debug, Merge)]
#[serde(deny_unknown_fields)]
pub struct Conda {
#[merge(strategy = crate::utils::merge_strategies::vec_prepend_opt)]
env_names: Option<Vec<String>>,

#[merge(strategy = crate::utils::merge_strategies::vec_prepend_opt)]
env_paths: Option<Vec<String>>,
}

#[derive(Deserialize, Default, Debug, Merge)]
#[serde(deny_unknown_fields)]
#[allow(clippy::upper_case_acronyms)]
Expand Down Expand Up @@ -496,6 +506,9 @@ pub struct ConfigFile {
#[merge(strategy = crate::utils::merge_strategies::commands_merge_opt)]
commands: Option<Commands>,

#[merge(strategy = crate::utils::merge_strategies::inner_merge_opt)]
conda: Option<Conda>,

#[merge(strategy = crate::utils::merge_strategies::inner_merge_opt)]
python: Option<Python>,

Expand Down Expand Up @@ -958,6 +971,22 @@ impl Config {
&self.config_file.commands
}

/// The list of additional named conda environments.
pub fn conda_env_names(&self) -> Option<&Vec<String>> {
self.config_file
.conda
.as_ref()
.and_then(|conda| conda.env_names.as_ref())
}

/// The list of additional git repositories to pull.
pub fn conda_env_paths(&self) -> Option<&Vec<String>> {
self.config_file
.conda
.as_ref()
.and_then(|conda| conda.env_paths.as_ref())
}

/// The list of additional git repositories to pull.
pub fn git_repos(&self) -> Option<&Vec<String>> {
self.config_file.git.as_ref().and_then(|git| git.repos.as_ref())
Expand Down

0 comments on commit 097063f

Please sign in to comment.