| Crates.io | globby |
| lib.rs | globby |
| version | 0.2.4 |
| created_at | 2025-04-19 10:30:46.012873+00 |
| updated_at | 2025-08-16 06:50:56.548685+00 |
| description | Heavily opinionated glob matching library |
| homepage | |
| repository | https://github.com/ClementNerma/Globby |
| max_upload_size | |
| id | 1640547 |
| size | 75,687 |
Globby is a small ~1k LoC library designed for searching all items in a given directory that match a glob pattern.
use globby::glob;
let pattern = glob("**/*.*").unwrap();
for path in pattern {
println!("{}", path.unwrap().display());
}
This library should work on any platform.
globThe well-known glob library is more polished and has a lot more options, but also opinionated defaults that differ from this library, such as:
** matches anything, including files an hidden directoriesThe syntax for patterns is as followed:
? matches any character* matches any suite of characters, or no character at all[abc] matches any of a, b or c[!abc] matches any character except a, b and c[\[] matches [. The list of escapable characters is [, ], {, }, *, ?, \, /, | and :
[abc\[] matches any of a, b, c or [[[:alpha:]] will match any alphabetic character. The list of character classes are:
:alpha: for any alphabetic character:digit: for any digit:alphanumeric: for any alphabetic character or digit:uppercase: for any uppercase character:lowercase: for any lowercase character:whitespace: for any whitespace character[![:alpha:]] will match any non-alphabetic character{a|bc} will match any of a or bc
{[[:alpha:]][![:digit]]|[[:digit:]]*} will match any alphabetic character followed by a non-digit character, OR a digit followed by anythingMatches are performed against path components, e.g. in /path/to/item components are path, to and item.
Matchers cannot match path separators.
/ or \ depending on the platform (Windows, Linux, macOS, ...)** will match any possible combination of directories. For instance, /**/*.txt will match any of /file.txt, /dir/file.txt, /dir/dir2/file.txt, and so on./dir will not match dir. Note that using a [crate::Walker] will not cause this problem as a base directory is used.This project is provided under the terms of the Apache 2.0 license.