ConsoleMenu-simple
2.4.3
Install-Package ConsoleMenu-simple -Version 2.4.3
dotnet add package ConsoleMenu-simple --version 2.4.3
<PackageReference Include="ConsoleMenu-simple" Version="2.4.3" />
paket add ConsoleMenu-simple --version 2.4.3
#r "nuget: ConsoleMenu-simple, 2.4.3"
// Install ConsoleMenu-simple as a Cake Addin
#addin nuget:?package=ConsoleMenu-simple&version=2.4.3
// Install ConsoleMenu-simple as a Cake Tool
#tool nuget:?package=ConsoleMenu-simple&version=2.4.3
ConsoleMenu
A simple, highly customizable, DOS-like console menu
Nuget package: https://www.nuget.org/packages/ConsoleMenu-simple
Usage
var subMenu = new ConsoleMenu(args, level: 1)
.Add("Sub_One", () => SomeAction("Sub_One"))
.Add("Sub_Two", () => SomeAction("Sub_Two"))
.Add("Sub_Three", () => SomeAction("Sub_Three"))
.Add("Sub_Four", () => SomeAction("Sub_Four"))
.Add("Sub_Close", ConsoleMenu.Close)
.Configure(config =>
{
config.Selector = "--> ";
config.EnableFilter = true;
config.Title = "Submenu";
config.EnableBreadcrumb = true;
config.WriteBreadcrumbAction = titles => Console.WriteLine(string.Join(" / ", titles));
});
var menu = new ConsoleMenu(args, level: 0)
.Add("One", () => SomeAction("One"))
.Add("Two", () => SomeAction("Two"))
.Add("Three", () => SomeAction("Three"))
.Add("Sub", subMenu.Show)
.Add("Change me", (thisMenu) => thisMenu.CurrentItem.Name = "I am changed!")
.Add("Close", ConsoleMenu.Close)
.Add("Action then Close", (thisMenu) => { SomeAction("Close"); thisMenu.CloseMenu(); })
.Add("Exit", () => Environment.Exit(0))
.Configure(config =>
{
config.Selector = "--> ";
config.EnableFilter = true;
config.Title = "Main menu";
config.EnableWriteTitle = true;
config.EnableBreadcrumb = true;
});
menu.Show();
Running app from console with pre-selected menu items
To do this, use public ConsoleMenu(string[] args, int level)
constructor during initialization.
Use double quotes for item names and digits for item numbers. Here are some examples:
--menu-select=0.1 //run first at level 0 and second at level 1
--menu-select="Sub.Sub_One.'Close...'" //run "Sub" at level 0 and "Sub_One" at level 1, and "Close..." at level 2
--menu-select="Sub.2" //run item "Sub" at level 0, and then run third item at level 1
Configuration
You can also define configuration via .Configure() method. The default config looks like:
public class MenuConfig
{
public ConsoleColor SelectedItemBackgroundColor = Console.ForegroundColor;
public ConsoleColor SelectedItemForegroundColor = Console.BackgroundColor;
public ConsoleColor ItemBackgroundColor = Console.BackgroundColor;
public ConsoleColor ItemForegroundColor = Console.ForegroundColor;
public Action WriteHeaderAction = () => Console.WriteLine("Pick an option:");
public Action<MenuItem> WriteItemAction = item => Console.Write("[{0}] {1}", item.Index, item.Name);
public string Selector = ">> ";
public string FilterPrompt = "Filter: ";
public bool ClearConsole = true;
public bool EnableFilter = false;
public string ArgsPreselectedItemsKey = "--menu-select=";
public char ArgsPreselectedItemsValueSeparator = '.';
public bool EnableWriteTitle = false;
public string Title = "My menu";
public Action<string> WriteTitleAction = title => Console.WriteLine(title);
public bool EnableBreadcrumb = false;
public Action<IReadOnlyList<string>> WriteBreadcrumbAction = titles => Console.WriteLine(string.Join(" > ", titles));
}
Example:
new ConsoleMenu()
.Add("One", () => SomeAction("One"))
.Add("Two", () => SomeAction("Two"))
.Add("Close", ConsoleMenu.Close)
.Configure(config => { config.Selector = "--> "; })
.Show();
Requirements
Framework compatible with .NET Standard 1.3 (.NET Core 1.0, .NET Framework 4.6, Mono 4.6) or higher.
Product | Versions |
---|---|
.NET | net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows |
.NET Core | netcoreapp1.0 netcoreapp1.1 netcoreapp2.0 netcoreapp2.1 netcoreapp2.2 netcoreapp3.0 netcoreapp3.1 |
.NET Standard | netstandard1.3 netstandard1.4 netstandard1.5 netstandard1.6 netstandard2.0 netstandard2.1 |
.NET Framework | net46 net461 net462 net463 net47 net471 net472 net48 |
MonoAndroid | monoandroid |
MonoMac | monomac |
MonoTouch | monotouch |
Tizen | tizen30 tizen40 tizen60 |
Universal Windows Platform | uap uap10.0 |
Xamarin.iOS | xamarinios |
Xamarin.Mac | xamarinmac |
Xamarin.TVOS | xamarintvos |
Xamarin.WatchOS | xamarinwatchos |
-
.NETStandard 1.3
- NETStandard.Library (>= 1.6.1)
-
net5.0
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on ConsoleMenu-simple:
Package | Downloads |
---|---|
Anixe.QualityTools
Additional tools for testing software |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
2.4.3 | 1,148 | 3/3/2022 |
2.4.2 | 1,539 | 1/9/2022 |
2.4.1 | 2,925 | 10/20/2021 |
2.4.0 | 29,519 | 9/2/2019 |
2.3.1 | 357 | 8/26/2019 |
2.3.0 | 335 | 8/26/2019 |
2.2.1 | 2,991 | 11/22/2018 |
2.2.0 | 1,309 | 11/20/2018 |
2.1.4 | 512 | 11/15/2018 |
2.1.3 | 521 | 11/12/2018 |
2.1.2 | 617 | 11/7/2018 |
2.1.1 | 1,224 | 5/28/2018 |
2.1.0 | 685 | 5/28/2018 |
2.0.0 | 630 | 5/15/2018 |
1.0.0 | 720 | 5/12/2018 |
- fix submenu re-entry incorrect behavior