Skip to content

Commit a3f3f7b

Browse files
authored
feat: add glob pattern expansion to CLI find search paths and environment directories (Fixes #354) (#362)
Expands glob patterns in `search_paths` and `environment_directories` when constructing the configuration for the `find` CLI command, using the `expand_glob_patterns` utility from `pet-fs`. - Call `expand_glob_patterns` on `search_paths` and `environment_directories` in `create_config()` - Uses the glob expansion introduced in #353 Fixes #354
1 parent e364131 commit a3f3f7b

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

crates/pet/src/lib.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use pet_core::os_environment::Environment;
1010
use pet_core::python_environment::PythonEnvironmentKind;
1111
use pet_core::Locator;
1212
use pet_core::{os_environment::EnvironmentApi, reporter::Reporter, Configuration};
13+
use pet_fs::glob::expand_glob_patterns;
1314
use pet_poetry::Poetry;
1415
use pet_poetry::PoetryLocator;
1516
use pet_python_utils::cache::set_cache_directory;
@@ -138,8 +139,8 @@ fn create_config(options: &FindOptions) -> Configuration {
138139
let mut config = Configuration::default();
139140

140141
let mut search_paths = vec![];
141-
if let Some(dirs) = options.search_paths.clone() {
142-
search_paths.extend(dirs);
142+
if let Some(dirs) = options.search_paths.as_ref() {
143+
search_paths.extend(expand_glob_patterns(dirs));
143144
}
144145
// If workspace folders have been provided do not add cwd.
145146
if search_paths.is_empty() {
@@ -168,10 +169,12 @@ fn create_config(options: &FindOptions) -> Configuration {
168169
config.conda_executable = options.conda_executable.clone();
169170
config.pipenv_executable = options.pipenv_executable.clone();
170171
config.poetry_executable = options.poetry_executable.clone();
171-
config.environment_directories = options
172-
.environment_directories
173-
.clone()
174-
.map(|dirs| dirs.into_iter().filter(|p| p.is_dir()).collect());
172+
config.environment_directories = options.environment_directories.as_ref().map(|dirs| {
173+
expand_glob_patterns(dirs)
174+
.into_iter()
175+
.filter(|p| p.is_dir())
176+
.collect()
177+
});
175178

176179
config
177180
}

0 commit comments

Comments
 (0)