Skip to content
ConsoleMonster
Class

MenuContext

ConsoleMonster.Interactive

Namespace
ConsoleMonster.Interactive
Assembly
ConsoleMonster
Modifiers
sealed

What an action gets from the menu: the item, the submitted form values, prompts drawn over the app, toasts, a live dashboard run that returns to the menu with a results summary, and navigation.

Inheritance

  • object
  • MenuContext

Usage

Explore 33 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.

Accepted by parameters 22

Methods

public T? Ask<T>(Prompt<T?> prompt) #

Asks a prompt in front of the app and returns the answer.

Type Parameters

T
The answer type.

Parameters

prompt ConsoleMonster.Interactive.Prompt<T?> required
The prompt.

Returns

T? The answer.
public bool Confirm(string question, bool defaultValue = false) #

Asks a yes/no question in front of the app.

Parameters

question string required
The question.
defaultValue bool = false optional
The default answer.

Returns

bool The answer.
public void Exit() #

Leaves the menu.

public void Log(string text, StatusKind status = Info) #

Reports a line of output from the action. While the app owns the screen the line is kept and shown when the action returns (a toast for one line, an output dialog for several) instead of being drawn over the app; in the inline layout it is written to the console.

Parameters

text string required
The line.
status ConsoleMonster.Styling.StatusKind = Info optional
Info for plain output, Warn or Fail to colour it.
public void Open(MenuItem item) #

Opens an item (its submenu, form, selection or page).

Parameters

item ConsoleMonster.Interactive.MenuItem required
The item.
public MenuRunResult Run(IWidget dashboard, Func<RunContext, MenuRunResult?> work, LiveSessionOptions? options = null) #

Runs work with a live dashboard on the app's screen; when the work returns, the menu comes back and shows the result with its next actions. Prompts during the run pause the dashboard and appear in front of it.

Parameters

dashboard ConsoleMonster.Layout.IWidget required
The dashboard.
work System.Func<ConsoleMonster.Interactive.RunContext, ConsoleMonster.Interactive.MenuRunResult?> required
The work; returns the result to show (null shows a plain "done").
options ConsoleMonster.Live.LiveSessionOptions? = null optional
Live session options; the output is managed by the menu.

Returns

MenuRunResult The result.
public void ShowResult(MenuRunResult result) #

Shows a result page (summary and next actions) in the content area.

Parameters

result ConsoleMonster.Interactive.MenuRunResult required
The result.
public void Toast(string text, StatusKind status = Pass) #

Shows a short notice in the footer.

Parameters

text string required
The text.
status ConsoleMonster.Styling.StatusKind = Pass optional
The status (mark and colour).

Properties

public Menu Menu { get; } #

The root menu.

public MenuItem? Item { get; } #

The item whose action runs, if any.

public FormValues? Values { get; } #

The values of the submitted form, if the action follows a form.

public FormResult? FormResult { get; internal set; } #

The form result, if the action follows a form.

public CancellationToken CancellationToken { get; } #

Cancelled when the menu ends (or Esc cancels an asynchronous action).

public MenuLayout Layout { get; } #

The menu layout in use.