fix(direnv): move symbol & rc_path into map

resolves: https://github.com/starship/starship/pull/6389#issuecomment-2480559116
This commit is contained in:
0x57e11a 2024-11-16 11:10:14 -08:00
parent 1121a93eb5
commit f7a083ee19
No known key found for this signature in database

View File

@ -40,15 +40,6 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
let parsed = StringFormatter::new(config.format).and_then(|formatter| {
formatter
.map_meta(|variable, _| match variable {
"symbol" => Some(config.symbol),
"rc_path" => match state.rc_path.to_str() {
None => {
log::warn!("direnv rc path has non UTF-8 characters");
None
}
ret => ret,
},
"allowed" => Some(match state.allowed {
AllowStatus::Allowed => config.allowed_msg,
AllowStatus::NotAllowed => config.not_allowed_msg,
@ -64,6 +55,11 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
"style" => Some(Ok(config.style)),
_ => None,
})
.map(|variable| match variable {
"symbol" => Some(Ok(Cow::from(config.symbol))),
"rc_path" => Some(Ok(state.rc_path.to_string_lossy())),
_ => None,
})
.parse(None, Some(context))
});