Acklann.GlobN 2.1.7

A netstandard library that allows you to effortlessy grab files via glob/minimatch patterns. Great for resolving relative paths coming from the command-line

Install-Package Acklann.GlobN -Version 2.1.7
dotnet add package Acklann.GlobN --version 2.1.7
<PackageReference Include="Acklann.GlobN" Version="2.1.7" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Acklann.GlobN --version 2.1.7
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

What is GlobN

GlobN is a file pattern matching library for that outperforms Regex (see benchmarks). Grabbing files from the command-line can never be easier.

How it works

Let say your current directory is as follows.

C:\projects\coolapp

index.html
js/
-- site.ts
-- site.js
-- viewModel/
   -- view.ts
   -- view.js

Most of the functions you'll be utilizing are extension methods. So lets say you want to grab all the files within the current directory.

string cd = System.Environment.CurrentDirectory;
IEnumerable<string> all5Files = cd.GetFiles();

Lets say your in the css folder and you want to grab all of the .js files.

var siteJs = cd.GetFiles("../js/*.js");
/* return: js\site.js */

var allJsFiles cd.GetFiles(@"..\**\*.js");
/* return: js\site.js; js\viewModel\view.js */

Finally, here are some other straight forward examples.

var filteredList = listOfPaths.Filter("*.js");

IEnumerable<string> files = @"..\js\*.ts".ResolvePath();

Glob glob = "*.png";
glob.IsMatch("/site/content/bg.png");

Supported Expressions

| Pattern | Description |
|---------|--------------------------------------------------------------------------------------------------|
| ..\ | Moves the current directory up one folder. Only applicable at the beginning of the pattern.
| * | Match zero or more characters excluding the directory separator.
| ** | Match zero or more directories.
| ? | Match a single character.
| ! | Negates the matching pattern. Only applicable at the beginning of the pattern.

NOTE: matches a case-insensitive.

What is GlobN

GlobN is a file pattern matching library for that outperforms Regex (see benchmarks). Grabbing files from the command-line can never be easier.

How it works

Let say your current directory is as follows.

C:\projects\coolapp

index.html
js/
-- site.ts
-- site.js
-- viewModel/
   -- view.ts
   -- view.js

Most of the functions you'll be utilizing are extension methods. So lets say you want to grab all the files within the current directory.

string cd = System.Environment.CurrentDirectory;
IEnumerable<string> all5Files = cd.GetFiles();

Lets say your in the css folder and you want to grab all of the .js files.

var siteJs = cd.GetFiles("../js/*.js");
/* return: js\site.js */

var allJsFiles cd.GetFiles(@"..\**\*.js");
/* return: js\site.js; js\viewModel\view.js */

Finally, here are some other straight forward examples.

var filteredList = listOfPaths.Filter("*.js");

IEnumerable<string> files = @"..\js\*.ts".ResolvePath();

Glob glob = "*.png";
glob.IsMatch("/site/content/bg.png");

Supported Expressions

| Pattern | Description |
|---------|--------------------------------------------------------------------------------------------------|
| ..\ | Moves the current directory up one folder. Only applicable at the beginning of the pattern.
| * | Match zero or more characters excluding the directory separator.
| ** | Match zero or more directories.
| ? | Match a single character.
| ! | Negates the matching pattern. Only applicable at the beginning of the pattern.

NOTE: matches a case-insensitive.

Release Notes

version 2.1.2
-------------
Fixes:
* ResolvePath not returning absolute paths.

version 2.1.0
-------------
Changes:
* Remove 'throwIfInvalid' from Glob constructor.
* Glob Extension methods 'expandVariable' no longer defaults to true.
* The 'SearchOption' enum has been added to the ResolvePath overloads.

Enhancements:
* IsMatch performance has been significantly improved.

version 1.0.7
-------------
Enhancements:
 * Make matches case-insensitive.

version 1.0.0
-------------
Features:
 * Suuports the following wildcards ('*', '**', '?').
 * Supports the path expansion for both environment variables and parent directories ('..\').
 * Supports pattern negating matches ('!').
 * Supports filtering list of paths.

  • .NETStandard 2.0

    • No dependencies.

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
2.1.7 269 9/9/2018
2.1.7-rc 176 7/2/2018
2.1.5-rc 177 7/1/2018
2.1.2-rc 208 7/1/2018
2.1.1-rc 168 6/29/2018
2.1.0-rc 173 6/28/2018
1.2.1 358 4/15/2018
1.1.0 285 3/9/2018
1.0.7 294 1/26/2018
1.0.6 276 1/10/2018
1.0.4 328 1/10/2018
1.0.1 289 1/8/2018