Trivial.Console
10.0.0
dotnet add package Trivial.Console --version 10.0.0
NuGet\Install-Package Trivial.Console -Version 10.0.0
<PackageReference Include="Trivial.Console" Version="10.0.0" />
<PackageVersion Include="Trivial.Console" Version="10.0.0" />
<PackageReference Include="Trivial.Console" />
paket add Trivial.Console --version 10.0.0
#r "nuget: Trivial.Console, 10.0.0"
#:package Trivial.Console@10.0.0
#addin nuget:?package=Trivial.Console&version=10.0.0
#tool nuget:?package=Trivial.Console&version=10.0.0
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 | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. net11.0 is compatible. |
| .NET Framework | net462 is compatible. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 is compatible. net481 was computed. |
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Trivial.Console:
| Package | Downloads |
|---|---|
|
Lark.OapiClient
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 10.0.0 | 0 | 11/17/2026 |
| 10.0.0-preview9 | 0 | 11/17/2026 |
| 10.0.0-preview8 | 64 | 11/13/2026 |
| 10.0.0-preview7 | 92 | 11/11/2026 |
| 10.0.0-preview6 | 86 | 11/6/2026 |
| 10.0.0-preview5 | 127 | 9/9/2026 |
| 10.0.0-preview4 | 140 | 9/2/2026 |
| 10.0.0-preview3 | 117 | 9/1/2026 |
| 10.0.0-preview2 | 137 | 7/3/2026 |
| 10.0.0-preview1 | 158 | 6/23/2026 |
| 9.9.0 | 53 | 11/16/2026 |
| 9.8.0 | 587 | 11/12/2025 |
| 9.7.0 | 391 | 8/7/2025 |
| 9.6.0 | 281 | 7/9/2025 |
| 9.5.0 | 303 | 6/1/2025 |
| 9.4.0 | 810 | 2/13/2025 |
| 9.3.0 | 263 | 1/26/2025 |
| 9.2.0 | 252 | 1/10/2025 |
| 9.1.0 | 227 | 12/24/2024 |
| 9.0.0 | 229 | 12/12/2024 |