Trivial.Console
6.3.0
.NET 5.0
This package targets .NET 5.0. The package is compatible with this framework or higher.
.NET Core 3.1
This package targets .NET Core 3.1. The package is compatible with this framework or higher.
.NET Standard 2.0
This package targets .NET Standard 2.0. The package is compatible with this framework or higher.
.NET Framework 4.6.1
This package targets .NET Framework 4.6.1. The package is compatible with this framework or higher.
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package Trivial.Console --version 6.3.0
NuGet\Install-Package Trivial.Console -Version 6.3.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="Trivial.Console" Version="6.3.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Trivial.Console --version 6.3.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Trivial.Console, 6.3.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Trivial.Console as a Cake Addin #addin nuget:?package=Trivial.Console&version=6.3.0 // Install Trivial.Console as a Cake Tool #tool nuget:?package=Trivial.Console&version=6.3.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Trivial.Console
This library includes a lot of useful rich command line controls.
Import
Add following namespace to your code file to use.
using Trivial.CommandLine;
Select
A beautiful list or table with customized style to the standard output stream
so that user just need press the arrow buttons and ENTER
in keyboard to select.
// Create an instance for adding items and setting options.
var col = new Trivial.Collection.SelectionData<string>();
// Add some items. For each item, you can set a hotkey, a display name and the data.
col.Add('a', "char a", "a");
col.Add('b', "char b", "b");
for (var i = 0; i < 120; i++)
{
col.Add("num " + i, i.ToString());
}
// Create an options for display.
var options = new SelectionOptions
{
// You can define a question string after the list.
Question = "Please select one: ",
// We can define the colors of the item selected.
SelectedForegroundConsoleColor = ConsoleColor.White,
SelectedBackgroundConsoleColor = ConsoleColor.Blue,
// The selected item will also be displayed after the question string.
// So you can define its color.
ItemForegroundConsoleColor = ConsoleColor.Cyan,
// At the end of the list, the tips will be displayed before user press any key.
// There is a default value and you can customize it.
// And you can disable it by set it as null.
Tips = "Tips: You can use arrow key to select and press ENTER key to continue.",
// Then you can define its color.
TipsForegroundConsoleColor = ConsoleColor.Yellow,
// You can define the prefix for the item and the one selected.
SelectedPrefix = "> ",
Prefix = " ",
// You can define the column count for the list.
Column = 5,
// You can define the maximum rows to displayed.
// A paging will be displayed if the count of the list is greater than it.
MaxRow = 10,
// Press ESC can cancel this selection.
// But you can enable the manual way by set a manual question
// so that user can type the words directly.
ManualQuestion = "Type: "
};
// Write it to the standard output stream and wait for user selection.
var result = DefaultConsole.Select(col, options);
// You can get the result.
DefaultConsole.WriteLine("The result is {0}.", result.Value);
Progress
A progress bar in terminal that can present the latest state during the specific task running.
// Define an options that you can custom the style.
var progressStyle = new ConsoleProgressStyle
{
ValueConsoleColor = ConsoleColor.White
};
// Ouput the component in console and get the progress instance to update.
var progress = DefaultConsole.WriteLine(progressStyle, "Processing");
// A time-consuming work here.
for (var i = 0; i <= 50; i++)
{
await Task.Delay(10);
// And report the progress updated.
progress.Report(0.02 * i);
}
JSON
Following is a sample to format JSON into terminal.
var json = new Trivial.Text.JsonObjectNode();
// and then add some properties to json.
DefaultConsole.WriteLine(json);
Linear gradient
Output a string with linear gradient.
DefaultConsole.WriteLine(new LinearGradientConsoleStyle(
ConsoleColor.Gray, // Fallback color.
Color.FromArgb(15, 250, 250), // From color.
Color.FromArgb(85, 168, 255)) // To color
{
Bold = true // Additional font style
},"Trivial Sample");
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 is compatible. net5.0-windows was computed. net6.0 is compatible. 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 | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 is compatible. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 is compatible. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 is compatible. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
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 | |
---|---|---|---|
9.0.0-preview5 | 0 | 11/30/2024 | |
9.0.0-preview4 | 66 | 11/22/2024 | |
9.0.0-preview3 | 61 | 11/16/2024 | |
9.0.0-preview2 | 81 | 11/1/2024 | |
9.0.0-preview1 | 96 | 10/27/2024 | |
8.0.0 | 185 | 9/8/2024 | |
8.0.0-preview1 | 114 | 2/21/2024 | |
7.2.0 | 1,130 | 11/16/2023 | |
7.1.0 | 233 | 5/8/2023 | |
7.0.0 | 431 | 1/20/2023 | |
6.6.0 | 552 | 11/9/2022 | |
6.5.1 | 444 | 6/28/2022 | |
6.5.0 | 428 | 6/28/2022 | |
6.4.0 | 472 | 4/14/2022 | |
6.3.0 | 461 | 3/8/2022 | |
6.2.0 | 2,201 | 1/30/2022 | |
6.1.0 | 458 | 1/23/2022 | |
6.0.0 | 307 | 1/1/2022 | |
5.2.0 | 327 | 12/15/2021 | |
5.1.0 | 292 | 12/2/2021 | |
5.0.0 | 290 | 11/27/2021 | |
4.0.0 | 327 | 11/9/2021 | |
3.9.0 | 322 | 12/15/2021 | |
3.8.0 | 402 | 11/9/2021 | |
3.7.2 | 589 | 4/22/2021 | |
3.7.1 | 441 | 4/20/2021 | |
3.7.0 | 505 | 3/17/2021 | |
3.6.0 | 723 | 11/12/2020 | |
3.5.2 | 821 | 4/14/2020 | |
3.5.1 | 893 | 4/12/2020 | |
3.5.0 | 974 | 4/1/2020 | |
3.4.0 | 1,070 | 2/20/2020 | |
3.3.0 | 1,234 | 2/14/2020 | |
3.2.0 | 1,601 | 1/22/2020 | |
3.1.0 | 1,617 | 12/30/2019 | |
3.0.1 | 1,519 | 12/26/2019 | |
2.2.0 | 1,245 | 2/19/2020 | |
2.1.0 | 1,665 | 12/24/2019 | |
2.0.0 | 1,574 | 8/31/2019 | |
1.2.0 | 1,649 | 5/20/2019 | |
1.1.0 | 1,557 | 5/8/2019 | |
1.0.0 | 1,576 | 5/1/2019 |