vertical-cli 1.0.0-dev.20240118.8

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.
dotnet add package vertical-cli --version 1.0.0-dev.20240118.8                
NuGet\Install-Package vertical-cli -Version 1.0.0-dev.20240118.8                
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.20240118.8" />                
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.20240118.8                
#r "nuget: vertical-cli, 1.0.0-dev.20240118.8"                
#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.20240118.8&prerelease

// Install vertical-cli as a Cake Tool
#tool nuget:?package=vertical-cli&version=1.0.0-dev.20240118.8&prerelease                

Vertical.Cli

A command line arguments parser.

Features

  • Define a single command or hierarchy of commands.
  • Binds parsed arguments to the public constructors, properties and fields of classes and records.
  • Suports POSIX, GNU, and Microsoft option syntax.
  • Built-in, configurable help system.
  • Defines validation methods for verbose unit testing of configuration.
  • Uses a source generator for efficient runtime execution and AOT trimming.

Quick look

> dotnet add package vertical-cli

// Define a type to receive parameters
record Parameters(FileInfo Source, FileInfo Dest, bool Overwrite);

// Define a root command
var rootCommand = RootCommand.Create<Parameters, Task>(
    id: "copy",
    root =>
    {
        // Configure options
        root.AddArgument(
            id: "source",
            validator: Validator.Configure<FileInfo>(x => x.FileExists()),
            description: "Path to the source file to copy")

            .AddArgument<FileInfo>(
                id: "dest",
                description: "Path to the destination file")
                
            .AddSwitch(
                id: "--overwrite", 
                description: "Whether to overwrite existing files");

        // Enables the "--help" option
        root.AddHelpOption();                

        root.AddDescription("Copies files");                

        // Receives the arguments and implements the application's logic
        root.SetHandler(async (Parameters param) => 
        {
            if (param.Dest.Exists && !param.Overwrite)
            {
                Console.WriteLine("Skipping operation (destination file exists).");
                return;
            }

            await File.Copy(param.source.FullName, param.dest.FullName);
        });            
    }
);

// Parse arguments & pass control to the handler delegate
await rootCommand.InvokeAsync(args);

Read the full docs.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos 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.