ConsoleToolkit 1.3.0-beta2

.NET Framework 4.0
This is a prerelease version of ConsoleToolkit.
There is a newer version of this package available.
See the version list below for details.
dotnet add package ConsoleToolkit --version 1.3.0-beta2
NuGet\Install-Package ConsoleToolkit -Version 1.3.0-beta2
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="ConsoleToolkit" Version="1.3.0-beta2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ConsoleToolkit --version 1.3.0-beta2
#r "nuget: ConsoleToolkit, 1.3.0-beta2"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install ConsoleToolkit as a Cake Addin
#addin nuget:?package=ConsoleToolkit&version=1.3.0-beta2&prerelease

// Install ConsoleToolkit as a Cake Tool
#tool nuget:?package=ConsoleToolkit&version=1.3.0-beta2&prerelease

A library providing a framework that allows you focus on the functionality you want to build rather than wasting your effort on the necessary but time consuming elements such as interpreting command line parameters, formatting help text, validating interactive input, and displaying data in a readable way. The toolkit contains extensive support in all these areas, presented in a way that requires minimal effort to use, and reduces your overall workload while ensuring that your application is a good command line citizen and has all the features command line users expect.

Console output can be word wrapped, and formatted into tables with full control over the formatting of table columns. The formatting services take the width of the console output window into account and will size table columns intelligently to make sure the output is readable.

Colours can be applied with exceptionally simple extension methods. For example:

console.WrapLine($"Displaying data from: {source.Yellow()}");

Instead of:

Console.Write("Displaying data from: ");
Console.ForegroundColor = ConsoleColor.Yellow;
Console.ForegroundColor = ConsoleColor.White;

Input can be accepted from the user in a variety of ways from a simple confirmation question:

if (console.Confirm("Are you sure?"))

To more advanced use cases involving accepting whole data structures worth of data or presenting menus.

Command line parameters can be specified using a straightforward attribute based mechanism in which you define a command class and decorate it to specify which of its properties represent parameters and options. For example:

   [Description("List directories")]
   public class DirCommand
       [Description("Optional path to list.")]
       public string Path { get; set; }

       public void Handle(IConsoleAdapter console, IErrorAdapter error)
           console.FormatTable(Directory.EnumerateFileSystemEntries(Path).Select(d => new { Directory = d }));

Attributes in the command definition are used to automatically generate command line help and to automatically validate the arguments supplied on the command line. No further work is required beyond defining the command handler class.

Product Versions
.NET Framework net40 net403 net45 net451 net452 net46 net461 net462 net463 net47 net471 net472 net48 net481
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

This package has 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
2.0.0 7,571 8/26/2018
1.4.1 1,419 2/8/2018
1.4.0-beta3 1,009 12/31/2017
1.4.0-beta2 843 11/23/2017
1.4.0-beta1 1,039 11/19/2017
1.3.4 1,193 11/8/2017
1.3.3 1,183 11/3/2017
1.3.2 1,165 10/29/2017
1.3.1 1,062 9/23/2017
1.3.0-beta3 1,071 9/5/2017
1.3.0-beta2 967 8/20/2017
1.3.0-beta 851 8/20/2017
1.2.0 1,309 12/11/2016
1.2.0-beta3 958 12/10/2016
1.2.0-beta2 958 12/5/2016
1.2.0-beta 958 12/2/2016
1.1.0 1,307 6/27/2016
1.0.1 1,563 7/9/2015 1,406 7/4/2015 1,371 6/19/2015 1,410 5/12/2015

Support for command keywords. This allows groups of commands to be specified e.g. "user add", "user block", "user delete". Here, "user" is the keyword and is associated with "add", "block" and "delete".
   Conversly, it could be speocified as "add user", "block user" and "delete user", in which the keywords are "add", "block" and "delete", each of which is associated with a discrete command with the name "user".