diff options
author | Matan Kushner <hello@matchai.me> | 2019-10-04 22:30:46 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-10-04 22:30:46 +0900 |
commit | 05210b9510b797f7738d5b2d51e8a6877f2d5283 (patch) | |
tree | 7399401dba9373f61035dbbd055f4137cd20f705 /src/modules/aws.rs | |
parent | e90a3768da7882db092b38d141cf8e19fabbee56 (diff) |
refactor: Go from Rust workspaces to a package with nested packages (#480)
Diffstat (limited to 'src/modules/aws.rs')
-rw-r--r-- | src/modules/aws.rs | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/modules/aws.rs b/src/modules/aws.rs new file mode 100644 index 000000000..fb8fabfa7 --- /dev/null +++ b/src/modules/aws.rs @@ -0,0 +1,27 @@ +use std::env; + +use super::{Context, Module}; + +use crate::config::RootModuleConfig; +use crate::configs::aws::AwsConfig; + +pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> { + const AWS_PREFIX: &str = "on "; + + let aws_profile = env::var("AWS_PROFILE").ok()?; + if aws_profile.is_empty() { + return None; + } + + let mut module = context.new_module("aws"); + let config: AwsConfig = AwsConfig::try_load(module.config); + + module.set_style(config.style); + + module.get_prefix().set_value(AWS_PREFIX); + + module.create_segment("symbol", &config.symbol); + module.create_segment("profile", &config.profile.with_value(&aws_profile)); + + Some(module) +} |