Skip to content
ConsoleMonster

API Reference

Class

Menu

Namespace ConsoleMonster.Interactive
Assembly ConsoleMonster
Source Menu.cs:32
Modifiers sealed

A menu tree: items that run actions, open submenus, forms, selections and pages. Menu.Run shows it as an app (Shell), a centred menu (Classic) or a scrollback list (Inline), with a breadcrumb, Back/Home/Exit, the command palette (Ctrl+K or :), the key map (?) and a footer generated from the active keys.

Inheritance

  • Object
  • Menu

Usage

Explore 8 API references to this type

This type appears in these public API surfaces even when no hand-authored example is attached directly to the page.

Returned or exposed by 6

Accepted by parameters 2

Constructors

public Menu(String title) #

Creates a menu.

Parameters

title System.String requiredposition: 0
The title (the app name for the root menu).

Methods

public Menu Add(MenuItem item) #
Returns: Menu

Adds an item.

Parameters

item ConsoleMonster.Interactive.MenuItem requiredposition: 0
The item.

Returns

The menu.

public Menu Exit(String? title = null) #
Returns: Menu

Adds the exit item.

Parameters

title System.String? = null optionalposition: 0
The title; null uses "Exit".

Returns

The menu.

public MenuItem? Find(String title) #
Returns: MenuItem?

Finds an item by title anywhere in the tree.

Parameters

title System.String requiredposition: 0
The title.

Returns

The item, or null.

public Menu Item(String title, Action<MenuItem>? configure = null) #
Returns: Menu

Adds an item and configures it.

Parameters

title System.String requiredposition: 0
The title.
configure System.Action<ConsoleMonster.Interactive.MenuItem>? = null optionalposition: 1
Configures the item.

Returns

The menu.

public Void Run(MenuOptions? options = null, CancellationToken cancellationToken = default) #
Returns: Void

Shows the menu until the user exits.

Parameters

options ConsoleMonster.Interactive.MenuOptions? = null optionalposition: 0
Options.
cancellationToken System.Threading.CancellationToken = default optionalposition: 1
Ends the menu.
public Task RunAsync(MenuOptions? options = null, CancellationToken cancellationToken = default) #
Returns: Task

Shows the menu on a worker thread until the user exits.

Parameters

options ConsoleMonster.Interactive.MenuOptions? = null optionalposition: 0
Options.
cancellationToken System.Threading.CancellationToken = default optionalposition: 1
Ends the menu.

Returns

Completion.

public Menu Separator(String? title = null) #
Returns: Menu

Adds a divider with an optional heading.

Parameters

title System.String? = null optionalposition: 0
The heading, or null.

Returns

The menu.

Properties

public String Title { get; set; } #

The title.

public String? Description { get; set; } #

A sentence shown above the items.

public String? Subtitle { get; set; } #

Muted text at the right of the title bar (a version, an environment).

public MenuLayout Layout { get; set; } #

The layout this menu prefers when MenuOptions.Layout is Auto.

public IList<MenuItem> Items { get; } #

The items.

public IList<ICommandProvider> CommandProviders { get; } #

Extra sources for the command palette.

public IList<KeyBinding> KeyBindings { get; } #

App-wide key bindings (shown in the key map and, by priority, in the footer).