![]() |
VOOZH | about |
dotnet add package ConsoleUserInteractionHelper --version 4.0.0
NuGet\Install-Package ConsoleUserInteractionHelper -Version 4.0.0
<PackageReference Include="ConsoleUserInteractionHelper" Version="4.0.0" />
<PackageVersion Include="ConsoleUserInteractionHelper" Version="4.0.0" />Directory.Packages.props
<PackageReference Include="ConsoleUserInteractionHelper" />Project file
paket add ConsoleUserInteractionHelper --version 4.0.0
#r "nuget: ConsoleUserInteractionHelper, 4.0.0"
#:package ConsoleUserInteractionHelper@4.0.0
#addin nuget:?package=ConsoleUserInteractionHelper&version=4.0.0Install as a Cake Addin
#tool nuget:?package=ConsoleUserInteractionHelper&version=4.0.0Install as a Cake Tool
ConsoleHelper is a versatile .NET library designed to simplify console-based user interactions. It provides a rich set of methods to handle various input scenarios, from simple string inputs to complex numeric constraints.
Install ConsoleHelper via NuGet Package Manager:
Install-Package ConsoleUserInteractionHelper
Or via .NET CLI:
dotnet add package ConsoleUserInteractionHelper
Here are some examples to demonstrate the versatility of ConsoleHelper:
using ConsoleUserInteractionHelper;
var helper = new ConsoleHelper();
// Get a non-empty string
string name = helper.GetNonEmptyStringFromUser();
// Get a positive integer with max 3 retry attempts
int age = helper.GetPositiveInt(maxRetries: 3);
// Use custom constraints for integer input
int evenNumber = helper.GetIntWithConstraints(
n => n % 2 == 0,
"Please enter an even number."
);
// Collect a password securely
string password = helper.GetSecretStringFromUser();
// Display a spinner during a long operation
Task longRunningTask = SomeLongRunningOperation();
helper.ShowSpinnerUntilTaskIsRunning(longRunningTask);
// Get a file path with specific extension
string filePath = helper.GetPathToExistingFileFromUser(".txt");
ConsoleHelper is designed with extensibility in mind. You can easily create custom input methods using the generic GetIntWithConstraints method:
// Custom method to get a prime number
public int GetPrimeNumber(int? maxRetries = null)
{
return GetIntWithConstraints(
n => IsPrime(n),
"Please enter a prime number.",
maxRetries
);
}
private bool IsPrime(int number)
{
if (number < 2) return false;
for (int i = 2; i <= Math.Sqrt(number); i++)
{
if (number % i == 0) return false;
}
return true;
}
We welcome contributions! Please see our for more details.
ConsoleHelper is released under the .
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 net5.0 was computed. net5.0-windows net5.0-windows was computed. net6.0 net6.0 was computed. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 was computed. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
| .NET Core | netcoreapp3.0 netcoreapp3.0 was computed. netcoreapp3.1 netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.1 netstandard2.1 is compatible. |
| MonoAndroid | monoandroid monoandroid was computed. |
| MonoMac | monomac monomac was computed. |
| MonoTouch | monotouch monotouch was computed. |
| Tizen | tizen60 tizen60 was computed. |
| Xamarin.iOS | xamarinios xamarinios was computed. |
| Xamarin.Mac | xamarinmac xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos xamarinwatchos was computed. |
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 4.0.0 | 2,020 | 9/10/2024 |
| 3.4.1 | 622 | 8/30/2023 |
| 3.3.0 | 530 | 11/18/2021 |
| 3.2.3 | 513 | 11/7/2021 |
| 3.2.2 | 544 | 11/7/2021 |
| 3.2.1 | 504 | 11/4/2021 |
| 3.2.0 | 535 | 11/4/2021 |
| 3.1.0 | 514 | 11/3/2021 |
| 3.0.0 | 517 | 11/3/2021 |
| 2.2.0 | 593 | 2/20/2021 |
| 2.1.0 | 589 | 2/14/2021 |
| 2.0.0 | 1,286 | 10/8/2018 |
| 1.1.0 | 1,033 | 10/7/2018 |
| 1.0.0 | 1,028 | 10/7/2018 |
# ConsoleUserInteractionHelper
## Release Notes (v4.0.0)
This major update brings significant improvements and new features to enhance your console application development experience.
### What's New
- **Generic Integer Input Method**: Introduced `GetIntWithConstraints` for flexible integer input handling.
- **Optional Max Retries**: All input methods now support an optional maximum retry limit.
- **Improved Error Handling**: Enhanced error messages and consistency across all methods.
### Breaking Changes
- Signature changes to existing methods to incorporate the optional `maxRetries` parameter.