-
-
Notifications
You must be signed in to change notification settings - Fork 223
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(core): improve PathExt::replace_env
and use it throught the codebase
#1375
base: master
Are you sure you want to change the base?
Conversation
Apologies, I totally didn't see that trait, I should've dug deeper 🙏 . I think the implementation should be in I think I will just move the implementation and tests there. Is there a reason why your trait was not used instead of |
ExpandEnvVars
trait to handle environment variable expansion in pathsPathExt::replace_env
and use it instead of resolve_home_path
The long term goal is definitely to make sure what can do what PathExt is doing everywhere we read a Path-like string in every workspace crate - let's target this for v0.1.36 🤞 |
I basically only wanted to fix that issue linked in my PR, so I did not want to change everything. I did not forget about it but seems like someone else had the same idea with the paths 😉 Thank you for this PR! |
@amrbashir Can we use this PR to unify the handling across all workspace crates? |
yeah definitely, I will get on it |
PathExt::replace_env
and use it instead of resolve_home_path
PathExt::replace_env
and use it throught the codebase
@LGUG2Z this should be ready, I searched throughout the code base for It is possible that I might have missed a few places due to my unfamiliarity with the code base, so if you find any, please let me know. Most of the paths that needed this trait, are in:
That said, I would appreciate a second eye and some extra testing. |
This new implementation allows for expanding any environment variable so it is not limited to just
~
,$HOME
,$Env:USERPROFILE
and$Env:KOMOREBI_CONFIG_HOME
.It expands the follwing formats:
%variable%
$Env:variable
$variable
.Why?
Just for convenience, for example instead of
$HOME/AppData/Roaming/applications.json
, it can be$APPDATA/applications.json
Remaining questions?
resolve_home_path
function be removed? It is not just a wrapper around the new trait.ExpandEnvVars::expand_vars
return a result when a variable doesn't exit in env or keep the path as is (current behavior)?