FSC-Terminal
1.1.0
See the version list below for details.
dotnet add package FSC-Terminal --version 1.1.0
NuGet\Install-Package FSC-Terminal -Version 1.1.0
<PackageReference Include="FSC-Terminal" Version="1.1.0" />
paket add FSC-Terminal --version 1.1.0
#r "nuget: FSC-Terminal, 1.1.0"
// Install FSC-Terminal as a Cake Addin #addin nuget:?package=FSC-Terminal&version=1.1.0 // Install FSC-Terminal as a Cake Tool #tool nuget:?package=FSC-Terminal&version=1.1.0
FSC.Terminal
A better version of the console class in C#
What is FSC.Terminal?
Terminal is the same like the console class. It uses generics in some methods and offers the possibility to write a hidden password. You can choose a password char or just use nothing like in the most linux software. Try it out and you will notice how similar it is to the default console class, but still so much advanced
Example Script
using FSC;
namespace ConsoleApp1
{
internal class Program
{
static void Main(string[] args)
{
Terminal.Title = "Example";
Terminal.WriteLine("Welcome!");
Terminal.WriteLine();
string? name = Terminal.ReadLine("Please enter your username: ");
string? password = Terminal.ReadLine("Please enter your password: ", TerminalPasswordMode.Hide);
Terminal.WriteLine("Thank you. You are logged in. If you want to see your inputted data, write yes");
if (Terminal.ReadLine() == "yes")
{
Terminal.WriteLine($"Username: {name}{Environment.NewLine}Password: {password}");
}
Terminal.ReadKey();
}
}
}
Output
Welcome!
Please enter your username: JohnDoe
Please enter your password:
Thank you. You are logged in. If you want to see your inputted data, write yes
yes
Username: JohnDoe
Password: 12345678
If you choose the right password mode, the password will not be visible
Example Script 2
Terminal.WriteLine("Hello User,");
string[] starSelection = { "*", "**", "***", "****", "*****" };
int index = ReadSelection("if you like, what we do, rate us with 5 stars, please", starSelection);
if (index >= 0 && index <= 2)
{
Terminal.WriteLine("Oh, we are sorry to hear about this sad feedback");
}
else
{
Terminal.WriteLine("Wow, thank you for your feedback");
}
Terminal.ReadKey();
The index is the index of the array or list that is given
Output 2
Hello User,
if you like, what we do, rate us with 5 stars, please
> *
**
***
****
*****
After pressing enter
Hello User,
if you like, what we do, rate us with 5 stars, please
*****
Wow, thank you for your feedback
Example Script 3
bool userAgreed = Terminal.ReadYesNo("Do you agree our ToS and privacy policy?", 'y', 'N')
The user can only input y or N. This can not be canceled with the escape key.
How a program could look like:
using FSC;
namespace TestApp
{
internal class Program
{
static void Main(string[] args)
{
Terminal.Title = "Delivery Service - Login";
Terminal.WriteLine("Hello and welcome. What is your name?");
string? username = Terminal.ReadLine("Username: ");
bool showPassword = Terminal.ReadYesNo("Do you want to show your Password as * or keep it totally invisible? Choose between ", '*', 'i');
Terminal.WriteLine("Awesome.");
string? password = Terminal.ReadLine("Please enter your password: ", showPassword ? TerminalPasswordMode.HideByChar : TerminalPasswordMode.Hide);
if (username != "john" || password != "doe")
{
Terminal.WriteLine("We are sorry, this account is not part of our organisation.");
Terminal.ReadKey(true);
return;
}
Terminal.WriteLine("Great, you are logged in!");
Thread.Sleep(2_000);
Terminal.Clear();
Terminal.Title = "Delivery Service";
string[] foodOfTheDay = { "Greek food", "Chinese food", "Italian food", "German food", "French food", "American food" };
int index = Terminal.ReadSelection("Today is random food day, but you may still select, what kind of food you want (Press Escape to cancel the order):", true, foodOfTheDay);
if (index == -1)
{
Terminal.WriteLine("Oh, we are sorry to hear that. We hope you change your mind and come back soon.");
Terminal.ReadKey(true);
return;
}
Thread.Sleep(2_000);
DateTime time = DateTime.Now;
while (true)
{
Terminal.Clear();
Terminal.WriteLine($"Thank you for ordering at <Delivery Service>. Your order #{index}#{foodOfTheDay[index]}# got submitted and will arrive in {(time - DateTime.Now).Minutes + 25} minutes.");
Thread.Sleep(60_000);
}
}
}
}
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 is compatible. 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 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net46 is compatible. net461 was computed. net462 was computed. net463 was computed. net47 is compatible. 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. |
-
.NETFramework 4.6
- No dependencies.
-
.NETFramework 4.7
- No dependencies.
-
.NETFramework 4.8
- No dependencies.
-
.NETStandard 2.0
- No dependencies.
-
net6.0
- No dependencies.
-
net7.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.
Added ReadYesNo request and ReadSelection for letting the user choose an item out of an array or a list