Retrospection.CommandLine
0.0.1.2
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
<PackageReference Include="Retrospection.CommandLine" Version="0.0.1.2" />
paket add Retrospection.CommandLine --version 0.0.1.2
#r "nuget: Retrospection.CommandLine, 0.0.1.2"
// 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 | Versions 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. |
-
.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.
Initial Release to NuGet