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,741 | 8/26/2018 |
1.4.1 | 2,003 | 2/8/2018 |
1.4.0-beta3 | 1,100 | 12/31/2017 |
1.4.0-beta2 | 925 | 11/23/2017 |
1.4.0-beta1 | 1,116 | 11/19/2017 |
1.3.4 | 1,323 | 11/8/2017 |
1.3.3 | 1,299 | 11/3/2017 |
1.3.2 | 1,293 | 10/29/2017 |
1.3.1 | 1,197 | 9/23/2017 |
1.3.0-beta3 | 1,128 | 9/5/2017 |
1.3.0-beta2 | 1,062 | 8/20/2017 |
1.3.0-beta | 927 | 8/20/2017 |
1.2.0 | 1,555 | 12/11/2016 |
1.2.0-beta3 | 1,042 | 12/10/2016 |
1.2.0-beta2 | 1,037 | 12/5/2016 |
1.2.0-beta | 1,040 | 12/2/2016 |
1.1.0 | 1,422 | 6/27/2016 |
1.0.1 | 1,708 | 7/9/2015 |
1.0.0.27 | 1,540 | 7/4/2015 |
1.0.0.26 | 1,518 | 6/19/2015 |
1.0.0.25 | 1,553 | 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".