Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/distantcam/cui
A simple Console UI
https://github.com/distantcam/cui
Last synced: 10 days ago
JSON representation
A simple Console UI
- Host: GitHub
- URL: https://github.com/distantcam/cui
- Owner: distantcam
- License: mit
- Created: 2017-03-02T03:09:46.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-06-06T02:53:05.000Z (over 7 years ago)
- Last Synced: 2024-11-15T00:32:57.059Z (2 months ago)
- Language: C#
- Size: 8.79 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: license.txt
Awesome Lists containing this project
README
# CUI
**CUI** provides a simple state based console UI with screens and a menu system for creating sample applications.### Example code
```
using System;
using System.Threading.Tasks;
using CUI;class Program
{
enum Screens
{
MainScreen,
Processes,
Process1,
Process2
}static void Main(string[] args)
{
var app = new ConsoleApplication(Screens.MainScreen);app.AddMenuScreen(Screens.MainScreen)
.WithMenuOption('p', "Select Process to run", Screens.Processes)
.WithMenuOption('q', "Quit");app.AddMenuScreen(Screens.Processes)
.WithMenuOption("Task 1 (long)", Screens.Process1)
.WithMenuOption("Task 2 (short)", Screens.Process2);app.AddFunctionScreen(Screens.Process1)
.SetAction(async () =>
{
Console.WriteLine("Running...");
await Task.Delay(1000);
Console.WriteLine("Almost done...");
await Task.Delay(1000);
Console.WriteLine("Just finishing up...");
await Task.Delay(1000);
Console.WriteLine("Done!");
});app.AddFunctionScreen(Screens.Process2)
.SetAction(() =>
{
Console.WriteLine("I'm done already!");
return Task.CompletedTask;
});app.Run();
// Or app.RunAsync().GetAwaiter().GetResult();
}
}
```