cup_cli/config/
build.rs

1use crate::config::{Language, LanguageConfig, Shelling};
2
3#[derive(Debug, Clone, Default, serde::Serialize, serde::Deserialize)]
4pub struct BuildConfig {
5    pub jobs: Option<usize>,
6    pub languages: Option<LanguageConfig>,
7}
8
9impl Shelling<Build> for BuildConfig {
10    fn shelling(self) -> Build {
11        Build {
12            jobs: self
13                .jobs
14                .map(|th| {
15                    if th == 0 {
16                        let cpus = std::thread::available_parallelism();
17                        if let Ok(cpus) = cpus { cpus.get() } else { 1 }
18                    } else {
19                        th
20                    }
21                })
22                .unwrap_or(1),
23            languages: self.languages.unwrap_or_default().shelling(),
24        }
25    }
26}
27
28#[derive(Debug, Clone)]
29pub struct Build {
30    pub jobs: usize,
31    pub languages: Language,
32}