Retrospection.CommandLine 0.0.1.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package Retrospection.CommandLine --version 0.0.1.2                
NuGet\Install-Package Retrospection.CommandLine -Version 0.0.1.2                
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="Retrospection.CommandLine" Version="0.0.1.2" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Retrospection.CommandLine --version 0.0.1.2                
#r "nuget: Retrospection.CommandLine, 0.0.1.2"                
#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 Retrospection.CommandLine as a Cake Addin
#addin nuget:?package=Retrospection.CommandLine&version=0.0.1.2

// Install Retrospection.CommandLine as a Cake Tool
#tool nuget:?package=Retrospection.CommandLine&version=0.0.1.2                

Retrospection.CommandLine

Version 0.0.1.0002 Release Notes

  • Added XML comments to source
  • Created this documentation for NuGet page

Purpose

To eliminate much of the boilerplate code that goes with writing command line applications, make validating command line arguments a lot easier, and provide auto-complete and menu services via the keyboard.

Known Issues (v.Current)

  • Documentation is sorely lacking
  • Menu customization needs to be exposed for public consumption
  • Various edge cases need testing
  • Help Text Generator formatting is poor

Getting Started

There are (currently) two main classes of interest that do all the heavy lifting. ActionInferer<T> and IntelliPrompt. The remaining public classes are attribute-derived types that support these.

ActionInferer

This provides the ability to map string arguments directly to methods and properties on a class which have been advertised via the Cmd and Prm attributes respectively.

Simple Example:

using Retrospection.CommandLine;

class Program
{
    [Prm] internal static string Filename { get; set; }

    [Cmd] internal static void Run() => System.Diagnostics.Process.Start(Filename);
    
    static void Main(string[] args)
    {
        var ai = new ActionInferer<Program>(args);
        ai.Invoke();

        // Assuming the executable was launched like this:
        // myprogram.exe run --filename=notepad.exe
        // It will set the Filename property to "notepad.exe" and then invoke the Run method.
    }
}

More detailed examples showing instance methods, validation and help text are coming soon.

IntelliPrompt

This provides a command line prompt which supports command history, customizable auto-complete, better cursor navigation, and a menu.

Simple Example:

using Retrospection.CommandLine;

class Program
{
    static void Main(string[] args)
    {
        var opts = new[] { "Kirk", "Picard", "Sisko", "Janeway", "Archer", "Pike" };
        var prompt = new IntelliPrompt(null, opts, null);
        prompt.AutoCompleteMode = AutoCompleteMode.StartsWith;
        
        while (true)
        {
            var s = prompt.ReadLine("$");
            Console.WriteLine();
            Console.WriteLine($" You entered: {s}");
        }
    }
}

Run the above application and try typing "A" and then hitting the tab key. You can also hit the context menu key on the keyboard (to the left of the right-most Ctrl key on most full-size keyboards) to get a menu of the available commands. Hitting Escape will close the menu.

More detailed examples demonstrating custom auto-complete and a structured command system are coming soon.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  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 was computed.  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.
  • .NETStandard 2.1

    • 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.

Version Downloads Last updated
0.0.2.5 421 5/6/2021
0.0.1.4 306 4/6/2021
0.0.1.3 322 3/26/2021
0.0.1.2 300 3/21/2021
0.0.1.1 300 3/19/2021

Initial Release to NuGet