MST.Tools
0.3.1
dotnet add package MST.Tools --version 0.3.1
NuGet\Install-Package MST.Tools -Version 0.3.1
<PackageReference Include="MST.Tools" Version="0.3.1" />
<PackageVersion Include="MST.Tools" Version="0.3.1" />
<PackageReference Include="MST.Tools" />
paket add MST.Tools --version 0.3.1
#r "nuget: MST.Tools, 0.3.1"
#:package MST.Tools@0.3.1
#addin nuget:?package=MST.Tools&version=0.3.1
#tool nuget:?package=MST.Tools&version=0.3.1
MST.Tools
MST.Tools is a collection of useful console utilities for .NET CLI applications.
It provides features like themed output, colored text, structured menus, and input helpers.
β¨ Features
- Colorful output with custom RGB themes
- Menu helpers for CLI apps
- User input validation (string, int, decimal)
- Exit confirmation prompts
- Works on Windows, Linux, and macOS
- Supports .NET Standard 2.0 and above
π¦ Installation
dotnet add package MST.Tools
π§ Usage
You can import the namespace normally:
using MST.Tools;
class Program
{
static void Main()
{
ConsoleHelper.PrintSuccess("Operation completed successfully!");
ConsoleHelper.PrintError("Something went wrong!");
}
}
Or, if you donβt want to type ConsoleHelper.
every time, you can use the static import:
//use static import like this :
using static MST.Tools.ConsoleHelper;
class Program
{
static void Main()
{
// and you can use methods without typing 'ConsoleHelper.' every time
Ok("Data saved correctly.");
Fail("Failed to connect to server.");
Warn("Low disk space.");
Info("Loading configuration...");
}
}
π¨ Theming
You can fully customize colors with RGB values (0-255
) or hex codes (#RRGGBB
).
using static MST.Tools.ConsoleHelper;
class Program
{
static void Main()
{
//you can set theme colors in hex format or R,G,B format
SetTheme("#2DC653", "#A0A0A0", "#FFD23F");
}
}
Reset theme back to default:
ResetTheme();
Set error color:
SetErrorColor("255,0,0");
π UI Helpers
Sections and Dividers
Section("User Menu");
Divider();
Menu Items
MenuItem(1, "Start Application");
MenuItem(2, "Settings");
MenuItem(3, "Exit");
Results and Items
PrintResult("Username", "MST");
ShowItem(42, "Special Item");
Customizing Outputs
you can override the default theme colors for UI elements on a per-call basis to draw attention to important information.
Here is a combined example showing how you can use these customizations together to build a richer UI:
Section("System Diagnostics");
Info("Choose a system to check:");
// Highlight the "Network" option which requires attention
MenuItem(1, "CPU");
MenuItem(2, "Memory");
MenuItem(
number: 3,
text: "Network (High Latency Detected)",
numberFg: "#FFB300", // Gold
textFg: "255,215,0" // Lighter Gold
);
// Show a result with custom colors to indicate a warning status
PrintResult(
label: "Overall Status",
result: "Action Required",
labelFg: "#D3D3D3", // Light Gray
valueFg: "#FFA500" // Orange
);
// List critical processes and highlight one that has stalled
Info("Running critical processes:");
ShowItem(2041, "system.core.service");
ShowItem(
id: 3155,
item: "data.backup.agent (Stalled)",
idFg: "#FF6347", // Tomato Red
itemFg: "#FF8C00" // Dark Orange
);
β¨οΈ Input Helpers
Simple Input
string name = GetInput("Enter your name:");
Integer Input
int age = GetIntInput("Enter your age:");
Decimal Input
decimal price = GetDecimalInput("Enter product price:");
Customizing Input Prompts
By default, input prompts use the theme's Secondary color for the label (the prompt text) and the Primary color for the input symbol (β). You can easily override these on a per-call basis using the labelFg and cursorFg parameters. This allows for creating visually distinct prompts for different questions without changing the global theme.
Here is a complete example demonstrating all parameters for GetIntInput:
int specialNumber = GetIntInput(
prompt: "Enter a special number between 40 and 50",
min: 40,
max: 50,
labelFg: "#9370DB", // A custom purple color for the label
cursorFg: "#FFD700" // A custom gold color for the arrow
);
Ok($"Success! Your special number is: {specialNumber}");
// The same customization can be applied to GetInput and GetDecimalInput.
string reason = GetInput(
prompt: "Why did you choose this number?",
labelFg: "173, 216, 230" // Light Blue
);
Confirm / Exit
if (Confirm("Do you want to continue?"))
{
Ok("Confirmed!");
}
if (ExitOption())
{
Fail("Exiting program...");
}
β Example Output
β Operation completed successfully!
β Something went wrong!
β Loading configuration...
βοΈ Advanced Configuration
If you're running the application in an environment that doesn't support Unicode symbols (like older Windows cmd.exe
), you can force an ASCII-only symbol set.
// Force ASCII symbols like "[OK]" and "[X]" instead of "β" and "β"
SetSymbolSet(SymbolSet.Ascii);
Ok("This will now be prefixed with [OK].");
π License
MIT License Β© 2025 MST.Tools
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. 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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. 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. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. 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. |
-
.NETStandard 2.0
- No dependencies.
-
net6.0
- 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.