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
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Jeninnet.FileQuery.CommandLine" Version="1.2.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Jeninnet.FileQuery.CommandLine" Version="1.2.1" />
                    
Directory.Packages.props
<PackageReference Include="Jeninnet.FileQuery.CommandLine" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Jeninnet.FileQuery.CommandLine --version 1.2.1
                    
#r "nuget: Jeninnet.FileQuery.CommandLine, 1.2.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Jeninnet.FileQuery.CommandLine@1.2.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Jeninnet.FileQuery.CommandLine&version=1.2.1
                    
Install as a Cake Addin
#tool nuget:?package=Jeninnet.FileQuery.CommandLine&version=1.2.1
                    
Install as a Cake Tool

Jeninnet.FileQuery.CommandLine

GitHub Actions CI Workflow Status GitHub release GitHub contributors GitHub stars GitHub license

NuGet Version NuGet downloads

Command-line argument binding for Jeninnet.FileQuery.


✨ Repo Stats

Repobeats analytics image


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 configure FileQueryBuilder.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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.2.1 291 6/17/2026
1.2.0 300 6/17/2026
1.1.0 312 6/14/2026
1.0.0 306 6/2/2026