Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(config): move all uses of clap(env) to config #9113

Merged
merged 15 commits into from
Sep 11, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
chore(config): factor out ui logic
  • Loading branch information
chris-olszewski committed Sep 5, 2024
commit 3c6e9282d561fbce55e0183061fac660095fb3ea
25 changes: 12 additions & 13 deletions crates/turborepo-lib/src/config/env.rs
Original file line number Diff line number Diff line change
@@ -202,26 +202,25 @@ impl<'a> OverrideEnvVars<'a> {
output_map,
})
}

fn ui(&self) -> Option<UIMode> {
let value = self
.environment
.get(OsStr::new("ci"))
.or_else(|| self.environment.get(OsStr::new("no_color")))?;
match truth_env_var(value.to_str()?)? {
true => Some(UIMode::Stream),
false => None,
}
}
}

impl<'a> ResolvedConfigurationOptions for OverrideEnvVars<'a> {
fn get_configuration_options(
&self,
_existing_config: &ConfigurationOptions,
) -> Result<ConfigurationOptions, Error> {
let ui = self
.environment
.get(OsStr::new("ci"))
.or_else(|| self.environment.get(OsStr::new("no_color")))
.and_then(|value| {
// If either of these are truthy, then we disable the TUI
if value == "true" || value == "1" {
Some(UIMode::Stream)
} else {
None
}
});

let ui = self.ui();
let output = ConfigurationOptions {
team_id: self.output_map.get("team_id").cloned(),
token: self.output_map.get("token").cloned(),