Skip to content

A library that gives functionality to the console (Progressbar, selection menu, acceptance field)

License

Notifications You must be signed in to change notification settings

KimPiks/ConsoleFeatures

Repository files navigation

ConsoleFeatures

A library that gives functionality to the console (Progressbar, selection menu, acceptance field)

Docs

  • void Progressbar(int value, int min = 0, int max = 100, string information = "")
    Shows a progressbar

    • int value - Progressbar value
    • int min - Progressbar minimum value (default 0)
    • int max - Progressbar minimum value (default 100)
    • string information - Additional information (e.q. download speed)
    • ArgumentOutOfRangeException - The exception is returned when the progressbar value is outside its range (min < = value < = max)
  • int Selector(List<string> options, int selectedIndex = 0)
    Shows a form with options to choose from

    • List<string> options - List of options to choose from
    • int selectedIndex - Currently selected option, no need to specify, needed for recursion
    • Return - The index of the selected option
  • bool Acceptance(string text, bool approvalRequired = false)
    Shows acceptable condition (Y/N)

    • string text - Acceptable condition
    • bool approvalRequired - Whether the user must accept the terms to proceed
    • Return - Whether the user has accepted the terms
  • void ClearLastLine()
    Clears the last console line

Example

using Console = ConsoleFeatures.Console;

System.Console.WriteLine("Progressbar");

Random rand = new();
for (var i = 0; i <= 100; i++)
{
    var downloadSpeed = rand.NextInt64(1, 20);
    Console.Progressbar(i, information: $"{downloadSpeed} Mb/s");
    Thread.Sleep(100);
}

System.Console.Write("\n");

System.Console.WriteLine("Selector");

var options = new List<string>()
{
    "First option",
    "Second option",
    "Third option"
};

var selectedOptionIndex = Console.Selector(options);
System.Console.WriteLine($"Selected option: {options[selectedOptionIndex]}");

System.Console.Write("\n");
System.Console.WriteLine("Acceptance");

var accepted = Console.Acceptance("Do you accept sth?");
System.Console.WriteLine(accepted.ToString());

System.Console.Write("\n");

Console.Acceptance("Do you accept sth? required", true);

About

A library that gives functionality to the console (Progressbar, selection menu, acceptance field)

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Languages