Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

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();
}
}
```