[PR #1375] [CLOSED] feat(core): improve PathExt::replace_env and use it throught the codebase #1365

Closed
opened 2026-01-05 14:55:02 +01:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/LGUG2Z/komorebi/pull/1375
Author: @amrbashir
Created: 3/25/2025
Status: Closed

Base: masterHead: feat/expand-vars-trait


📝 Commits (10+)

  • 803c95e feat(core): add ExpandEnvVars trait to handle environment variable expansion in paths
  • cb16102 clippy
  • e3d1418 var_os
  • 9145e3b move to PathExt
  • 7db56b2 refactor komorebic crate to use PathExt::repalce_env
  • 92bedd1 refactor komorebi-bar crate to use PathExt::replace_env
  • 8f834ee fmt
  • 23b8623 refactor komorebi crate to use PathExt::repalce_env
  • 5da5564 Merge branch 'master' into feat/expand-vars-trait
  • e52850a leftovers

📊 Changes

12 files changed (+448 additions, -236 deletions)

View changed files

📝 Cargo.lock (+76 -0)
📝 komorebi-bar/src/bar.rs (+10 -6)
📝 komorebi-bar/src/main.rs (+20 -26)
📝 komorebi-client/src/lib.rs (+1 -1)
📝 komorebi/Cargo.toml (+1 -0)
📝 komorebi/src/core/mod.rs (+42 -51)
📝 komorebi/src/core/pathext.rs (+173 -29)
📝 komorebi/src/lib.rs (+10 -9)
📝 komorebi/src/main.rs (+2 -0)
📝 komorebi/src/static_config.rs (+52 -44)
📝 komorebi/src/windows_api.rs (+1 -1)
📝 komorebic/src/main.rs (+60 -69)

📄 Description

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:

  • CMD: %variable%
  • PowerShell: $Env:variable
  • Bash: $variable.

Why?

Just for convenience, for example instead of $HOME/AppData/Roaming/applications.json, it can be $APPDATA/applications.json

Remaining questions?

  • Should resolve_home_path function be removed? It is not just a wrapper around the new trait.
  • Should ExpandEnvVars::expand_vars return a result when a variable doesn't exit in env or keep the path as is (current behavior)?

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/LGUG2Z/komorebi/pull/1375 **Author:** [@amrbashir](https://github.com/amrbashir) **Created:** 3/25/2025 **Status:** ❌ Closed **Base:** `master` ← **Head:** `feat/expand-vars-trait` --- ### 📝 Commits (10+) - [`803c95e`](https://github.com/LGUG2Z/komorebi/commit/803c95ef9de0ebb9cfd45d3bd841ca86182b2143) feat(core): add ExpandEnvVars trait to handle environment variable expansion in paths - [`cb16102`](https://github.com/LGUG2Z/komorebi/commit/cb16102efc1f85f7c49185c52709c9de0b48a498) clippy - [`e3d1418`](https://github.com/LGUG2Z/komorebi/commit/e3d14189736f1eb1ae4d49042b1a78670dbf203b) var_os - [`9145e3b`](https://github.com/LGUG2Z/komorebi/commit/9145e3b13a6ee87e3d640ed6445c67b0b7e7c9ea) move to PathExt - [`7db56b2`](https://github.com/LGUG2Z/komorebi/commit/7db56b2567c5bbe68f01862e7a8cf72c4a0db86b) refactor `komorebic` crate to use `PathExt::repalce_env` - [`92bedd1`](https://github.com/LGUG2Z/komorebi/commit/92bedd1f6b8185bd4b1fca26afd9fe708b13ebaf) refactor `komorebi-bar` crate to use PathExt::replace_env - [`8f834ee`](https://github.com/LGUG2Z/komorebi/commit/8f834ee7b31aa0c16a7c402741f67681f4895dc1) fmt - [`23b8623`](https://github.com/LGUG2Z/komorebi/commit/23b86232500076495b115b4ca5d4a528bdc31bc4) refactor `komorebi` crate to use `PathExt::repalce_env` - [`5da5564`](https://github.com/LGUG2Z/komorebi/commit/5da5564146192053fcd64cc2a90f44f989a72a4a) Merge branch 'master' into feat/expand-vars-trait - [`e52850a`](https://github.com/LGUG2Z/komorebi/commit/e52850aaa719717c00ccfbad0ef04e63316b71f1) leftovers ### 📊 Changes **12 files changed** (+448 additions, -236 deletions) <details> <summary>View changed files</summary> 📝 `Cargo.lock` (+76 -0) 📝 `komorebi-bar/src/bar.rs` (+10 -6) 📝 `komorebi-bar/src/main.rs` (+20 -26) 📝 `komorebi-client/src/lib.rs` (+1 -1) 📝 `komorebi/Cargo.toml` (+1 -0) 📝 `komorebi/src/core/mod.rs` (+42 -51) 📝 `komorebi/src/core/pathext.rs` (+173 -29) 📝 `komorebi/src/lib.rs` (+10 -9) 📝 `komorebi/src/main.rs` (+2 -0) 📝 `komorebi/src/static_config.rs` (+52 -44) 📝 `komorebi/src/windows_api.rs` (+1 -1) 📝 `komorebic/src/main.rs` (+60 -69) </details> ### 📄 Description 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: - CMD: `%variable%` - PowerShell: `$Env:variable` - Bash: `$variable`. #### Why? Just for convenience, for example instead of `$HOME/AppData/Roaming/applications.json`, it can be `$APPDATA/applications.json` #### Remaining questions? - Should `resolve_home_path` function be removed? It is not just a wrapper around the new trait. - Should `ExpandEnvVars::expand_vars` return a result when a variable doesn't exit in env or keep the path as is (current behavior)? --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2026-01-05 14:55:02 +01:00
adam closed this issue 2026-01-05 14:55:02 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/komorebi#1365