diff options
author | Thomas O'Donnell <andytom@users.noreply.github.com> | 2019-09-26 04:55:47 +0200 |
---|---|---|
committer | Kevin Song <chipbuster@users.noreply.github.com> | 2019-09-25 21:55:47 -0500 |
commit | b050c597081967cbe7135d294f0cf43c2ec7608d (patch) | |
tree | f352a022b49ad9fb1b5d5fed1effe549b3e08e2f /src/modules | |
parent | 80a9e7b9a638e4e695be8280a9baff3550037111 (diff) |
feat: Add AWS module (#419)
Adds a module for displaying the current AWS profile based
on the AWS_PROFILE envar.
Diffstat (limited to 'src/modules')
-rw-r--r-- | src/modules/aws.rs | 29 | ||||
-rw-r--r-- | src/modules/mod.rs | 2 |
2 files changed, 31 insertions, 0 deletions
diff --git a/src/modules/aws.rs b/src/modules/aws.rs new file mode 100644 index 000000000..65ca05142 --- /dev/null +++ b/src/modules/aws.rs @@ -0,0 +1,29 @@ +use std::env; + +use ansi_term::Color; + +use super::{Context, Module}; + +pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> { + const AWS_CHAR: &str = "☁️ "; + 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 module_style = module + .config_value_style("style") + .unwrap_or_else(|| Color::Yellow.bold()); + module.set_style(module_style); + + module.get_prefix().set_value(AWS_PREFIX); + + module.new_segment("symbol", AWS_CHAR); + module.new_segment("profile", &aws_profile); + + Some(module) +} diff --git a/src/modules/mod.rs b/src/modules/mod.rs index 405906188..c1618252d 100644 --- a/src/modules/mod.rs +++ b/src/modules/mod.rs @@ -1,4 +1,5 @@ // While adding out new module add out module to src/module.rs ALL_MODULES const array also. +mod aws; mod character; mod cmd_duration; mod directory; @@ -27,6 +28,7 @@ use crate::module::Module; pub fn handle<'a>(module: &str, context: &'a Context) -> Option<Module<'a>> { match module { + "aws" => aws::module(context), "directory" => directory::module(context), "character" => character::module(context), "nodejs" => nodejs::module(context), |