Cliffer 0.4.16-prerelease

This is a prerelease version of Cliffer.
dotnet add package Cliffer --version 0.4.16-prerelease
                    
NuGet\Install-Package Cliffer -Version 0.4.16-prerelease
                    
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="Cliffer" Version="0.4.16-prerelease" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Cliffer" Version="0.4.16-prerelease" />
                    
Directory.Packages.props
<PackageReference Include="Cliffer" />
                    
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 Cliffer --version 0.4.16-prerelease
                    
#r "nuget: Cliffer, 0.4.16-prerelease"
                    
#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.
#addin nuget:?package=Cliffer&version=0.4.16-prerelease&prerelease
                    
Install Cliffer as a Cake Addin
#tool nuget:?package=Cliffer&version=0.4.16-prerelease&prerelease
                    
Install Cliffer as a Cake Tool

Cliffer - Command Line Interface Library for .NET

Cliffer is a library built on top of Microsoft's System.CommandLine library. It provides the following features:

  • Attribute-based development, so that you can focus on writing the business logic you need and leave the boilerplate code to the library.
  • Automatic help-text generation.
  • Built-in support for REPL (read-eval-print loop) interaction.
  • Built-in support for macro definitions, both in configuration and in code.
  • Targeting multiple platforms with .NET.

Cliffer uses .NET attributed programming to define commands, options, arguments, parameters, etc., and it manages all the boilerplate logic for you so you can focus on writing your code and just declare your intentions for that code when you're ready to use it. Cliffer takes care of the rest.

Here is an example from the clic sample:

[Command("push", "Push one or more numbers onto the stack")]
[Argument(typeof(IEnumerable<double>), "values", "Numbers to push onto the stack", Cliffer.ArgumentArity.OneOrMore)]
internal class PushCommand {
    public int Execute(IEnumerable<double> values, Stack<double> stack) {
        stack.PushAll(values);
        return Result.Success;
    }
}

In this example, the Command attribute declares that the PushCommand class implements the push command. The Argument attribute declares that the command accepts one or more arguments of type double with the name values. The Execute method will be called when the user invokes the push command, and Cliffer will pass the arguments as well as any required services as parameters to the method.

Here is another example:

[Command("hello", "Say hello")]
[Argument(typeof(string), "addressee", "State whom you are greeting.")]
internal class HelloCommand {
    [Macro("sunshine", "Greet the morning sun.")]
    private static string sunshine => "hello Sunshine";

    public int Execute(string addressee) {
        if (string.IsNullOrEmpty(addressee)) {
            addressee = "World";
        }

        Console.WriteLine($"Hello, {addressee}!");
        return 0;
    }
}

In this example, the HelloCommand class implements the hello command. The Argument attribute declares that the command accepts a single argument of type string. The Macro attribute declares a macro that can be used to call hello with a pre-defined argument. The Execute method will be called when the user invokes the hello command.

Note that macros can be defined in the configuration file as well as in code, and if defined in code, they may be defined on any static string property in any class.

Demo Applications

There are three demo applications to demonstrate the features and capabilities of Cliffer:

  • ClifferDemo - A walkthrough of various Cliffer features.
  • Clic - A stack calculator implemented as a REPL (read/eval/print loop).
  • ClifferBasic - A BASIC interpreter in a REPL environment, like the old Commodore 64 or Apple ][ or TI-99/4A that so many of us grew up with.

Unfortunately, these are all in various stages of being built, but feel free to explore them or even add to them.

Product 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 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.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.