FileBasedApp.Toolkit.Spectre
1.4.0
dotnet add package FileBasedApp.Toolkit.Spectre --version 1.4.0
NuGet\Install-Package FileBasedApp.Toolkit.Spectre -Version 1.4.0
<PackageReference Include="FileBasedApp.Toolkit.Spectre" Version="1.4.0" />
<PackageVersion Include="FileBasedApp.Toolkit.Spectre" Version="1.4.0" />
<PackageReference Include="FileBasedApp.Toolkit.Spectre" />
paket add FileBasedApp.Toolkit.Spectre --version 1.4.0
#r "nuget: FileBasedApp.Toolkit.Spectre, 1.4.0"
#:package FileBasedApp.Toolkit.Spectre@1.4.0
#addin nuget:?package=FileBasedApp.Toolkit.Spectre&version=1.4.0
#tool nuget:?package=FileBasedApp.Toolkit.Spectre&version=1.4.0
FileBasedApp.Toolkit.Spectre
Optional Spectre.Console and Spectre.Console.Cli integration.
FileBasedApp.Toolkit.AnsiConsoleFactorycreates stderr and quiet consoles.FileBasedApp.Toolkit.CommandCli.ExtendedCommandSettingsadds exception-based validation, path resolution, environment fallback and settings-file loading.
This package references FileBasedApp.Toolkit, Spectre.Console and Spectre.Console.Cli, but does not depend on SimpleExec. Deserializers and FlexibleFilePath remain in core.
Migration (1.4.0-preview-01)
These types moved from FileBasedApp.Toolkit into this optional package. Add an explicit reference:
<PackageReference Include="FileBasedApp.Toolkit.Spectre" Version="1.4.0-preview-01" />
Namespaces remain unchanged, but the assembly move is a binary breaking change. Recompile existing consumers after adding the reference. The core package remains framework-neutral; it no longer brings in Spectre.Console or Spectre.Console.Cli.
Batch path validation
All protected TryGetFile, TryGetFiles, TryGetDirectory, and TryGetDirectories
overloads remain available for backward compatibility. They now forward to the public
static helpers on PathUtil in the core package, preserving their signatures and
caller-argument expressions. Existing subclass calls need no changes. For use outside
command settings, call PathUtil directly without adding a Spectre dependency; see
the core path-validation examples.
Inside an ExtendedCommandSettings subclass, use TryGetFiles and
TryGetDirectories to resolve arrays of candidate paths. Both return
AbsolutePath[] and support .NET 10 and .NET 11. Overloads accept predefined roots,
single absolute roots, or multiple roots through the existing params overload.
// Inside DoValidate():
AbsolutePath[] files = TryGetFiles(
["settings.json", "defaults.json"], shouldExist: true,
root: PredefinedRootPath.CurrentDirectory);
AbsolutePath[] directories = TryGetDirectories(
["input", "output"], allowEmpty: false, shouldExist: true,
root: PathUtil.GetCurrentWorkingFolder());
Null candidate arrays are rejected. TryGetFiles also rejects an empty array.
TryGetDirectories treats an empty array as a single empty candidate: allowEmpty
controls whether it can resolve to a root directory. For multiple candidates,
validation errors are collected into one InvalidOperationException; the base
Validate() method converts the exception message into a validation error.
Extended settings
The example below shows how to use the ExtendedCommandSettings class to validate file and directory paths.
using FileBasedApp.Toolkit;
using FileBasedApp.Toolkit.CommandCli;
using Spectre.Console;
using Spectre.Console.Cli;
using TruePath;
public class CustomCommandSettings : ExtendedCommandSettings
{
[CommandArgument(0, "<directory-path>")]
public string? Directory { get; set; }
[CommandOption("--filePath")]
public required string File { get; set; }
public AbsolutePath DirectoryPath { get; set; }
public AbsolutePath FilePath { get; set; }
protected override ValidationResult DoValidate()
{
// Evaluates the directory string.
DirectoryPath = TryGetDirectory(Directory,
allowEmpty: true,
shouldExist: true,
PredefinedRootPath.ExecutionFolder);
FilePath = TryGetFile(File, true, roots: [PathUtil.GetCurrentWorkingFolder(), PathUtil.GetExecutionFolder()]);
return base.DoValidate();
}
}
| 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. net11.0 is compatible. |
-
net10.0
- FileBasedApp.Toolkit (>= 1.4.0)
- Spectre.Console (>= 0.57.2)
- Spectre.Console.Cli (>= 0.57.2)
- TruePath (>= 2.0.0)
-
net11.0
- FileBasedApp.Toolkit (>= 1.4.0)
- Spectre.Console (>= 0.57.2)
- Spectre.Console.Cli (>= 0.57.2)
- TruePath (>= 2.0.0)
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.4.0 | 79 | 11/13/2026 |
- Update with support for .net sdk 11
- Spectre integration: add ExtendedCommandSettings.TryGetFiles and TryGetDirectories batch validation for .NET 10 and .NET 11, returning absolute path arrays and aggregating validation errors for multiple candidates.
- Add predefined-root and single-absolute-root forwarding overloads for batch path validation, with XML documentation.
- Expose TryGetFile, TryGetFiles, TryGetDirectory, and TryGetDirectories as public static PathUtil helpers in the core package without Spectre dependencies.
- Retain the protected ExtendedCommandSettings TryGet overloads as backward-compatible wrappers over PathUtil, preserving signatures and caller-argument expressions.
- Update the file-based app template to call PathUtil directly; add core path-helper and compatibility regression coverage.