WildPath 0.0.1
See the version list below for details.
dotnet add package WildPath --version 0.0.1
NuGet\Install-Package WildPath -Version 0.0.1
<PackageReference Include="WildPath" Version="0.0.1" />
paket add WildPath --version 0.0.1
#r "nuget: WildPath, 0.0.1"
// Install WildPath as a Cake Addin #addin nuget:?package=WildPath&version=0.0.1 // Install WildPath as a Cake Tool #tool nuget:?package=WildPath&version=0.0.1
WildPath
WildPath is a library for advanced file-system path resolution. It provides pattern matching and dynamic path traversal capabilities through expressions, making it ideal for file searches and build systems.
Features
- Advanced Wildcard Matching:
- Supports wildcards (
*
and**
) for flexible directory and file searches. (e.g.,a\**\
).
- Supports wildcards (
- Parent Traversal:
- Use
..
to navigate to the parent directory and...
to recursively traverse all parent directories.
- Use
- Exact Matching:
- Match specific directories by name.
- Tagged Search:
- Identify directories containing a marker file or subdirectory. (e.g.,
a\:tagged(.marker)\b
).
- Identify directories containing a marker file or subdirectory. (e.g.,
- Composable Expressions:
- Combine strategies for complex path resolutions, such as
...\\**\\kxd
.
- Combine strategies for complex path resolutions, such as
Installation
- Clone the repository:
git clone https://github.com/your-username/WildPath.git
- Build the project using your favorite IDE or CLI:
dotnet build
Usage
Basic Path Matching
using WildPath;
var result = PathResolver.Resolve("SubDir1\\SubSubDir1");
Console.WriteLine(result);
// Output (assuming current directory = "C:\\Test"): "C:\\Test\\SubDir1\\SubSubDir1"
Wildcard Search
Find a directory named kxd
:
var result = PathResolver.Resolve("...\\**\\kxd");
// Output: "C:\\Test\\SubDir1\\SubSubDir1\\bin\\Debug\\kxd"
Tagged Search
Find a directory containing .marker
and a specific subpath:
var result = PathResolver.Resolve("**\\:tagged(.marker):\\bin\\Debug");
// Output: "C:\\Test\\SubDir2\\SubSubDir1\\bin\\Debug"
Customized Path Resolution
To use a custom current directory, separator or even a different file system, you can new up a PathResolver
and use the same API:
using WildPath;
var currentDir = "C:\\Test";
var expression = "SubDir1\\SubSubDir1";
var resolver = new PathResolver(currentDir);
var result = resolver.Resolve(expression);
Console.WriteLine(result); // Output: "C:\\Test\\SubDir1\\SubSubDir1"
Expression Syntax
Symbol | Description |
---|---|
* |
Matches any single directory name. |
** |
Matches directories recursively. |
.. |
Moves to the parent directory. |
... |
Recursively traverses all parent directories. |
:tagged(x) |
Matches directories containing a file or folder named x . |
Testing
Run the test suite to validate functionality:
dotnet test
Example tests include:
- Wildcard and parent traversal.
- Directory matching with markers.
Contributing
- Fork the repository.
- Create a new branch:
git checkout -b feature-name
- Commit your changes and push to your fork:
git commit -m "Description of feature" git push origin feature-name
- Submit a pull request.
Todo
Limit recursive search depth:
...{1,3}\\**{1,3}\\:tagged(testhost.exe):\\fr
should only search 1-3 directories deep....{4}\\**{4}\\:tagged(testhost.exe):\\fr
should only search 4 directories deep.
Add cancellation token support
Like seriously, this libaray begs for being ddosed.
Not as serious todos:
Search by file content:
Be a little cray cray
...\\**\\:content(test.json, test):
should search for files containing the string "test".
Seach within zip files:
...\\**\\:zip(test.zip):\\fr
should search for files within a zip file named "test.zip".
License
This project is licensed under the MIT License.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Framework | net48 is compatible. net481 was computed. |
-
.NETFramework 4.8
- System.Memory (>= 4.6.0)
-
net8.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.