-
Notifications
You must be signed in to change notification settings - Fork 36
Description
Summary
The JSONRPC server expands glob patterns in workspace_directories, environment_directories, and search_paths via expand_glob_patterns() from pet-fs. The CLI find command does not — paths are passed through as-is, meaning quoted glob patterns like '**/.venv' or '/home/user/*/venv' are treated as literal paths and fail.
Current behavior
- Server: calls
expand_glob_patterns()on incoming paths inhandle_configureandhandle_refresh - CLI:
create_config()incrates/pet/src/lib.rspassessearch_pathsdirectly without glob expansion
Desired behavior
Always call expand_glob_patterns() on search paths and environment directories in create_config(). Since expand_glob_patterns() is a no-op for non-glob paths (returns the literal path), this is safe to apply unconditionally.
Implementation
In crates/pet/src/lib.rs, update create_config():
fn create_config(options: &FindOptions) -> Configuration {
let mut search_paths = vec![];
if let Some(dirs) = options.search_paths.clone() {
search_paths.extend(expand_glob_patterns(&dirs));
}
// ... rest of config
config.environment_directories = options.environment_directories.as_ref()
.map(|dirs| expand_glob_patterns(dirs).into_iter().filter(|p| p.is_dir()).collect());
}Shell interaction note
Shells expand unquoted globs before the program sees them, so:
pet find /home/user/*/venv— shell expands, pet receives literal paths (works fine)pet find '**/.venv'— shell passes literal glob, pet expands it (needs this fix)PET_SEARCH_PATHS='/home/user/*/venv,**/.venv'— env vars aren't shell-expanded, pet must expand (needs this fix)
The env var path is the primary use case for glob support. No need to heavily document glob patterns for CLI positional args.
Files to modify
crates/pet/src/lib.rs— addexpand_glob_patterns()call increate_config()
Depends on
- Add missing CLI arguments for
findandresolvecommands (with env var fallbacks) #353 (adds--environment-directoriesflag that also needs glob expansion)