ayun_environment/
instance.rs1use crate::Environment;
2use ayun_core::{
3 errors::ContainerError,
4 traits::{ErrorTrait, InstanceTrait},
5 Container, Error, Result,
6};
7
8impl InstanceTrait for Environment {
9 fn register(_: &Container) -> Result<Self, ContainerError> {
10 let environment = match Self::try_from_args() {
11 Ok(env) => env,
12 Err(_) => Self::try_from_assertion().map_err(Error::wrap)?,
13 };
14
15 #[cfg(feature = "color-eyre")]
16 if !environment.production() {
17 color_eyre::install().expect("Failed to install color eyre");
18 }
19
20 Ok(environment)
21 }
22}