summaryrefslogtreecommitdiffstats
path: root/src/modules/aws.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules/aws.rs')
-rw-r--r--src/modules/aws.rs27
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)
+}