vertical-cli
1.0.0-dev.20241206.4
Prefix Reserved
This is a prerelease version of vertical-cli.
There is a newer prerelease version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package vertical-cli --version 1.0.0-dev.20241206.4
NuGet\Install-Package vertical-cli -Version 1.0.0-dev.20241206.4
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="vertical-cli" Version="1.0.0-dev.20241206.4" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add vertical-cli --version 1.0.0-dev.20241206.4
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: vertical-cli, 1.0.0-dev.20241206.4"
#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.
// Install vertical-cli as a Cake Addin #addin nuget:?package=vertical-cli&version=1.0.0-dev.20241206.4&prerelease // Install vertical-cli as a Cake Tool #tool nuget:?package=vertical-cli&version=1.0.0-dev.20241206.4&prerelease
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
vertical-cli
Minimal, AOT friendly command line arguments parser.
Quick start
Install
dotnet add package vertical-cli --prerelease
Configure and run
// Define a model
public record ZipOptions(FileInfo Source, FileInfo Destination, bool Overwrite);
// Build an application with two commands
var app = new CliApplicationBuilder("gzip")
.RouteAsync<ZipOptions>("gzip create", async (model, cancelToken) => {
if (model.Destination.Exists && !model.Overwrite){
Console.WriteLine("Target file already exists");
return -1;
}
await using var inputStream = File.OpenRead(model.Source);
await using var outputStream = File.OpenWrite(model.Destination);
await using var zipStream = new GZipStream(outputStream, CompressionMode.Compress);
await inputStream.CopyToAsync(zipStream, cancelToken);
Console.WriteLine($"Compressed file {model.Destination} created.");
})
.RouteAsync<ZipOptions>("gzip extract", async (model, cancelToken) => {
if (model.Destination.Exists && !model.Overwrite){
Console.WriteLine("Target file already exists");
return -1;
}
await using var inputStream = File.OpenRead(model.Source);
await using var outputStream = File.OpenWrite(model.Destination);
await using var zipStream = new GZipStream(inputStream, CompressionMode.Decompress);
await zipStream.CopyToAsync(outputStream, cancelToken);
Console.WriteLine($"File {model.Source} extracted.");
})
.MapModel<ZipOptions>(map => map
.Argument(x => x.Source)
.Argument(x => x.Destination)
.Switch(x => x.Overwrite, ["--overwrite"]))
.Build();
await app.InvokeAsync(args);
// Run:
// $ gzip picture.png picture.gz --overwrite
Features
- Binds command line arguments to strongly typed models
- Configure positional arguments. options and switches using short and long form notations
- Define a hierarchy of commands each with derived models
- Uses a source generator to bind models removing the need for reflection (AOT friendly)
- Uses analyzers to provide wranings and errors for common misconfiguration issues
- Display generated help content
See full docs.
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. net9.0 is compatible. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- No dependencies.
-
net9.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.