ConsoleToolkit 1.2.0

.NET Framework 4.0
There is a newer version of this package available.
See the version list below for details.
dotnet add package ConsoleToolkit --version 1.2.0
NuGet\Install-Package ConsoleToolkit -Version 1.2.0
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.2.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ConsoleToolkit --version 1.2.0
#r "nuget: ConsoleToolkit, 1.2.0"
#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.2.0

// Install ConsoleToolkit as a Cake Tool
#tool nuget:?package=ConsoleToolkit&version=1.2.0

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,651 8/26/2018
1.4.1 1,427 2/8/2018
1.4.0-beta3 1,015 12/31/2017
1.4.0-beta2 849 11/23/2017
1.4.0-beta1 1,045 11/19/2017
1.3.4 1,198 11/8/2017
1.3.3 1,188 11/3/2017
1.3.2 1,170 10/29/2017
1.3.1 1,069 9/23/2017
1.3.0-beta3 1,075 9/5/2017
1.3.0-beta2 975 8/20/2017
1.3.0-beta 855 8/20/2017
1.2.0 1,319 12/11/2016
1.2.0-beta3 962 12/10/2016
1.2.0-beta2 962 12/5/2016
1.2.0-beta 962 12/2/2016
1.1.0 1,312 6/27/2016
1.0.1 1,569 7/9/2015 1,411 7/4/2015 1,376 6/19/2015 1,415 5/12/2015

Support for interactive command sessions.