Jeninnet.FileQuery.CommandLine
1.2.1
Requires NuGet 6.0.0 or higher.
dotnet add package Jeninnet.FileQuery.CommandLine --version 1.2.1
NuGet\Install-Package Jeninnet.FileQuery.CommandLine -Version 1.2.1
<PackageReference Include="Jeninnet.FileQuery.CommandLine" Version="1.2.1" />
<PackageVersion Include="Jeninnet.FileQuery.CommandLine" Version="1.2.1" />
<PackageReference Include="Jeninnet.FileQuery.CommandLine" />
paket add Jeninnet.FileQuery.CommandLine --version 1.2.1
#r "nuget: Jeninnet.FileQuery.CommandLine, 1.2.1"
#:package Jeninnet.FileQuery.CommandLine@1.2.1
#addin nuget:?package=Jeninnet.FileQuery.CommandLine&version=1.2.1
#tool nuget:?package=Jeninnet.FileQuery.CommandLine&version=1.2.1
Jeninnet.FileQuery.CommandLine
Command-line argument binding for Jeninnet.FileQuery.
✨ Repo Stats
This package integrates Jeninnet.FileQuery with the standard System.CommandLine parser. It automatically maps command-line arguments and flags to structured file-query patterns.
The command-line package produces pattern inputs for the core engine. Runtime observability features such as IProgress<FileQueryProgress>, FileQueryDiagnostic, and FileQueryErrorRecoveryOptions are configured on the resulting core query or execution call.
🚀 Installation
Install the CLI integration package via NuGet:
dotnet add package Jeninnet.FileQuery.CommandLine
🛠️ Usage Example
Because CommandLinePatternOptions uses a protected constructor to encourage customization, you must subclass it in your application.
1. Define CLI Options
using System.CommandLine;
using Jeninnet.FileQuery;
using Jeninnet.FileQuery.CommandLine;
// Define a custom class inheriting from CommandLinePatternOptions
public sealed class AppCliOptions : CommandLinePatternOptions
{
// You can add additional options here if needed
}
2. Configure Command Routing
using System.CommandLine;
using Jeninnet.FileQuery;
using Jeninnet.FileQuery.CommandLine;
var cliOptions = new AppCliOptions();
var rootCommand = new RootCommand("My custom file analysis tool");
// Register the pattern matching options onto the root command
foreach (var option in cliOptions.GetCommandOptions())
{
rootCommand.Add(option);
}
rootCommand.SetAction(parseResult =>
{
// 1. Build pattern dictionaries from the command-line arguments
var patterns = PatternBuilder.Build(parseResult, cliOptions);
// 2. Pass patterns directly into the fluent builder
var query = FileQuery.From(@"C:\repo-root")
.Where(patterns)
.Build();
var engine = FileQueryRuntime.Create();
foreach (var file in engine.Execute(query))
{
Console.WriteLine(file);
}
});
await rootCommand.InvokeAsync(args);
⚙️ Supported Command-Line Flags
The following options are exposed by CommandLinePatternOptions:
| Option Flag | Alias | Description | Pattern Interpretation |
|---|---|---|---|
--patterns |
-p |
Semicolon-delimited pattern string. | Auto-Classified via PatternClassifier into GitIgnore, Glob, or Regex. |
--gitignore |
Semicolon-delimited exclude pattern list. | Forced to GitIgnore syntax. | |
--glob |
Semicolon-delimited exclude pattern list. | Forced to Glob syntax. | |
--regex |
Semicolon-delimited exclude pattern list. | Forced to Regex syntax. |
🧠 Pattern Splitting and Fallback
- Semicolon Splitting: Delimited values (e.g.,
-p "*.txt;*.md;!temp.txt") are split and trimmed by PatternSplitter. - Default Fallback: If no pattern arguments are supplied by the user, the builder defaults to
!**(GitIgnore syntax: include all files recursively). - Core Observability: After CLI parsing, call
ExecuteAsync(query, progress, cancellationToken)or configureFileQueryBuilder.WithDiagnostics(...)to inspect runtime traversal and match decisions.
🚫 Limitations & Notes
- System.CommandLine Requirement: This package depends directly on
System.CommandLine. - Option Delimiters: Ensure pattern strings containing semicolons are properly quoted in terminal environments (e.g.,
--patterns "*.cs;!bin/").
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Jeninnet.FileQuery (>= 1.2.1)
- System.CommandLine (>= 2.0.9)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
See the Migration Guide: https://github.com/TarekNajem04/Jeninnet.FileQuery/blob/main/Migration.md