Skip to content
ConsoleMonster

API Reference

Class

MenuContext

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 19 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 8

Methods

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

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

Type Parameters

T
The answer type.

Parameters

prompt ConsoleMonster.Interactive.Prompt<T?> requiredposition: 0
The prompt.

Returns

The answer.

public Boolean Confirm(String question, Boolean defaultValue = false) #
Returns: Boolean

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

Parameters

question System.String requiredposition: 0
The question.
defaultValue System.Boolean = false optionalposition: 1
The default answer.

Returns

The answer.

public Void Exit() #
Returns: Void

Leaves the menu.

public Void Log(String text, StatusKind status = Info) #
Returns: Void

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 System.String requiredposition: 0
The line.
status ConsoleMonster.Styling.StatusKind = Info optionalposition: 1
Info for plain output, Warn or Fail to colour it.
public Void Open(MenuItem item) #
Returns: Void

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

Parameters

item ConsoleMonster.Interactive.MenuItem requiredposition: 0
The item.
public RunResult Run(IWidget dashboard, Func<RunContext, RunResult?> work, LiveSessionOptions? options = null) #
Returns: RunResult

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 requiredposition: 0
The dashboard.
work System.Func<ConsoleMonster.Interactive.RunContext, ConsoleMonster.Interactive.RunResult?> requiredposition: 1
The work; returns the result to show (null shows a plain "done").
options ConsoleMonster.Live.LiveSessionOptions? = null optionalposition: 2
Live session options; the output is managed by the menu.

Returns

The result.

public Void ShowResult(RunResult result) #
Returns: Void

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

Parameters

result ConsoleMonster.Interactive.RunResult requiredposition: 0
The result.
public Void Toast(String text, StatusKind status = Pass) #
Returns: Void

Shows a short notice in the footer.

Parameters

text System.String requiredposition: 0
The text.
status ConsoleMonster.Styling.StatusKind = Pass optionalposition: 1
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.