ConsoleToolkit 1.3.0-beta2
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
<PackageReference Include="ConsoleToolkit" Version="1.3.0-beta2" />
paket add ConsoleToolkit --version 1.3.0-beta2
#r "nuget: ConsoleToolkit, 1.3.0-beta2"
// 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.Write(source);
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:
[Command]
[Description("List directories")]
public class DirCommand
{
[Positional]
[Description("Optional path to list.")]
public string Path { get; set; }
[CommandHandler]
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 Compatible and additional computed target framework versions. |
---|---|
.NET Framework | net40 is compatible. net403 was computed. net45 was computed. net451 was computed. net452 was computed. net46 was computed. net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
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 | 13,814 | 8/26/2018 |
1.4.1 | 2,025 | 2/8/2018 |
1.4.0-beta3 | 1,104 | 12/31/2017 |
1.4.0-beta2 | 929 | 11/23/2017 |
1.4.0-beta1 | 1,120 | 11/19/2017 |
1.3.4 | 1,333 | 11/8/2017 |
1.3.3 | 1,308 | 11/3/2017 |
1.3.2 | 1,301 | 10/29/2017 |
1.3.1 | 1,208 | 9/23/2017 |
1.3.0-beta3 | 1,132 | 9/5/2017 |
1.3.0-beta2 | 1,066 | 8/20/2017 |
1.3.0-beta | 931 | 8/20/2017 |
1.2.0 | 1,566 | 12/11/2016 |
1.2.0-beta3 | 1,047 | 12/10/2016 |
1.2.0-beta2 | 1,041 | 12/5/2016 |
1.2.0-beta | 1,044 | 12/2/2016 |
1.1.0 | 1,429 | 6/27/2016 |
1.0.1 | 1,715 | 7/9/2015 |
1.0.0.27 | 1,547 | 7/4/2015 |
1.0.0.26 | 1,527 | 6/19/2015 |
1.0.0.25 | 1,564 | 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".