Skip to content
ConsoleMonster
Class

PathPrompt

ConsoleMonster.Interactive

Namespace
ConsoleMonster.Interactive
Assembly
ConsoleMonster
Modifiers
sealed

A file or folder path with completion: matching entries of the typed folder are listed under the box (folders first), Tab completes the common part or the focused entry, Up/Down move through the suggestions, and Enter checks that the path exists and is the right kind when required.

Inheritance

Usage

Explore 45 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

Constructors

public PathPrompt(string title) #

Creates a path prompt.

Parameters

title string required
The question.

Methods

public override string Describe(string value) #

The answer as text, for the summary line left in the scrollback.

Parameters

value string required
The answer.

Returns

string The text.

Properties

public PathKind Kind { get; set; } #

What is accepted.

public bool MustExist { get; set; } #

Whether the path must exist.

public string? BasePath { get; set; } #

The folder relative paths start from; null uses the current directory.

public IList<string> Extensions { get; } #

File extensions offered as suggestions (".csv", ".json"); empty offers every file.

public bool ShowHidden { get; set; } #

Whether hidden entries are suggested.

public int Suggestions { get; set; } #

How many suggestions are listed.

Extension Methods

public static PathPrompt BasePath(PathPrompt pathPrompt, string? value) #

Sets PathPrompt.BasePath: The folder relative paths start from; null uses the current directory.

Parameters

pathPrompt ConsoleMonster.Interactive.PathPrompt required
The instance.
value string? required
The value.

Returns

PathPrompt The same instance.

Examples

// C# initializer or property    // C# fluent
pathPrompt.BasePath = value;     Ui.PathPrompt().BasePath(value);
public static PathPrompt Default(PathPrompt pathPrompt, string value) #

Sets Prompt<string>.Default: The default answer: pre-selected, accepted with Enter, and returned in non-interactive sessions.

Parameters

pathPrompt ConsoleMonster.Interactive.PathPrompt required
The instance.
value string required
The value.

Returns

PathPrompt The same instance.

Examples

// C# initializer or property    // C# fluent
pathPrompt.Default = value;      Ui.PathPrompt().Default(value);
public static PathPrompt Description(PathPrompt pathPrompt, string? value) #

Sets Prompt<string>.Description: Help text under the question.

Parameters

pathPrompt ConsoleMonster.Interactive.PathPrompt required
The instance.
value string? required
The value.

Returns

PathPrompt The same instance.

Examples

// C# initializer or property      // C# fluent
pathPrompt.Description = value;    Ui.PathPrompt().Description(value);
public static PathPrompt Extension(PathPrompt pathPrompt, string item) #

Adds an item to PathPrompt.Extensions: File extensions offered as suggestions (".csv", ".json"); empty offers every file.

Parameters

pathPrompt ConsoleMonster.Interactive.PathPrompt required
The instance.
item string required
The item.

Returns

PathPrompt The same instance.
public static PathPrompt Extensions(PathPrompt pathPrompt, IEnumerable<string> items) #

Adds items to PathPrompt.Extensions: File extensions offered as suggestions (".csv", ".json"); empty offers every file.

Parameters

pathPrompt ConsoleMonster.Interactive.PathPrompt required
The instance.
items System.Collections.Generic.IEnumerable<string> required
The items, in order.

Returns

PathPrompt The same instance.
public static PathPrompt Kind(PathPrompt pathPrompt, PathKind value) #

Sets PathPrompt.Kind: What is accepted.

Parameters

pathPrompt ConsoleMonster.Interactive.PathPrompt required
The instance.
value ConsoleMonster.Interactive.PathKind required
The value.

Returns

PathPrompt The same instance.

Examples

// C# initializer or property    // C# fluent
pathPrompt.Kind = value;         Ui.PathPrompt().Kind(value);
public static PathPrompt MustExist(PathPrompt pathPrompt, bool value = true) #

Sets PathPrompt.MustExist: Whether the path must exist.

Parameters

pathPrompt ConsoleMonster.Interactive.PathPrompt required
The instance.
value bool = true optional
The value; true when omitted.

Returns

PathPrompt The same instance.

Examples

// C# initializer or property    // C# fluent
pathPrompt.MustExist = value;    Ui.PathPrompt().MustExist(value);
public static PathPrompt ParameterName(PathPrompt pathPrompt, string? value) #

Sets Prompt<string>.ParameterName: The parameter that supplies this value non-interactively (-Domain, --domain); named in the non-interactive error message.

Parameters

pathPrompt ConsoleMonster.Interactive.PathPrompt required
The instance.
value string? required
The value.

Returns

PathPrompt The same instance.

Examples

// C# initializer or property        // C# fluent
pathPrompt.ParameterName = value;    Ui.PathPrompt().ParameterName(value);
public static PathPrompt ShowHidden(PathPrompt pathPrompt, bool value = true) #

Sets PathPrompt.ShowHidden: Whether hidden entries are suggested.

Parameters

pathPrompt ConsoleMonster.Interactive.PathPrompt required
The instance.
value bool = true optional
The value; true when omitted.

Returns

PathPrompt The same instance.

Examples

// C# initializer or property     // C# fluent
pathPrompt.ShowHidden = value;    Ui.PathPrompt().ShowHidden(value);
public static PathPrompt Suggestions(PathPrompt pathPrompt, int value) #

Sets PathPrompt.Suggestions: How many suggestions are listed.

Parameters

pathPrompt ConsoleMonster.Interactive.PathPrompt required
The instance.
value int required
The value.

Returns

PathPrompt The same instance.

Examples

// C# initializer or property      // C# fluent
pathPrompt.Suggestions = value;    Ui.PathPrompt().Suggestions(value);
public static PathPrompt Title(PathPrompt pathPrompt, string value) #

Sets Prompt<string>.Title: The question.

Parameters

pathPrompt ConsoleMonster.Interactive.PathPrompt required
The instance.
value string required
The value.

Returns

PathPrompt The same instance.

Examples

// C# initializer or property    // C# fluent
pathPrompt.Title = value;        Ui.PathPrompt().Title(value);