ConsoleOptions Default { get; }
Source
Gets a default instance of ConsoleOptions.
Represents configurable startup options for AppSurface console applications.
ConsoleOptions Default { get; }
Source
Gets a default instance of ConsoleOptions.
ConsoleOutputMode OutputMode { get; set; }
Source
Gets or sets how the console app should balance command-owned output against ambient host lifecycle diagnostics.
The default value is ConsoleOutputMode.Default, which preserves the standard Generic Host behavior. Set this to ConsoleOutputMode.CommandFirst for public CLI tools whose help, validation, and progress output should stay command-centric.
List<Action<IServiceCollection>> CustomRegistrations { get; }
Source
Gets custom service registrations that should be applied after AppSurface's built-in console services.
Use this for advanced console hosting scenarios, such as injecting a custom CliFx.Infrastructure.IConsole implementation or additional logging providers for tests and embedded hosts.
void CheckForUnknownOptions(IConsole console)
Source
Analyzes the current command-line arguments to detect unknown or mistyped options after a command has failed and, when possible, displays suggestions for valid alternatives.
consoleThe console used to write diagnostic messages and option suggestions to the user.IOptionSuggester to present suggestions for any unknown options.Defines a contract for suggesting alternative options when an unknown option is provided.
Use this abstraction when command parsing should improve interactive UX for unpredictable user-typed options or dynamic option sets without coupling callers to a specific matching algorithm. Prefer direct parser validation, explicit enum checks, or fixed lookup errors for tiny static option sets and strict non-interactive flows where suggestions add noise instead of recovery value.
IReadOnlyList<string> GetSuggestions(string? unknownOption, IEnumerable<string>? validOptions)
Source
Gets a list of suggested options based on the unknown option and the list of valid options.
unknownOptionThe unknown option provided by the user, or null when parsing did not identify one.validOptionsThe valid options for the current command, or null when none are available.A non-null collection of suggested options.
GetSuggestions implementations should treat a null or empty unknownOption, or a null or empty validOptions sequence, as producing no suggestions. The returned IReadOnlyList{T} must be non-null, should not contain duplicates, and should be deterministic: relevance-first when a scorer exists, then alphabetical for ties. Use this method for recovery hints, not as the source of truth for whether an option is valid.
A base class for console application startup logic, extending the module-based initialization.
TModuleThe type of the root module.ConsoleStartup<TModule> WithOptions(Action<ConsoleOptions>? configureOptions = null)
Source
Registers an optional callback to customize ConsoleOptions and enables fluent chaining.
configureOptionsAn optional action invoked before startup context creation to modify console startup behavior.The same ConsoleStartup{TModule} instance to support fluent configuration.
Task RunAsync(string[] args)
Source
Runs the console application asynchronously using a startup context derived from the supplied arguments and configured console options.
argsCommand-line arguments supplied to the console application.A task that completes when the host run finishes.
void ConfigureAdditionalServices(StartupContext context, IServiceCollection services)
Source
Allows derived classes to register additional services.
contextThe startup context.servicesThe service collection.This class is used to run a console application with a specified startup class and module. This allows for further customization of the consoles startup process.
Task RunAsync(string[] args, Action<ConsoleOptions>? configureOptions = null)
Source
Runs the console application asynchronously using a custom startup class.
argsCommand-line arguments.configureOptionsAn optional delegate to customize ConsoleOptions before startup.A task representing the run operation.
This class is used to run a console application with a specified module and a generic startup.
TModuleThe type of the root module.Task RunAsync(string[] args, Action<ConsoleOptions>? configureOptions = null)
Source
Runs the console application asynchronously with a generic startup.
argsCommand-line arguments.configureOptionsAn optional delegate to customize ConsoleOptions before startup.A task representing the run operation.
A command that can execute a sequence of other commands. Parameters and options defined on the parent command are automatically forwarded to the child commands when they share the same property name. Required parameters of child commands are validated before any command in the chain is executed.
void Configure(CommandChainBuilder builder)
Source
Configures the sequence of commands to execute.
builderFluent builder to define the chain.Fluent builder used to configure the chain of commands.
CommandChainBuilder Add<TCommand>()
Source
Adds a command to the execution chain.
CommandChainBuilder AddIf<TCommand>(Func<bool> condition)
Source
Adds a command to the chain that will execute only when condition returns true.
Suggests options using the Levenshtein distance algorithm.
IReadOnlyList<string> GetSuggestions(string? unknownOption, IEnumerable<string>? validOptions)
Source
Gets a list of suggested options based on their Levenshtein distance to the unknown option.
unknownOptionThe unknown command line option.validOptionsThe list of valid command line options.A collection of suggested options that closely match the unknown option.
int ComputeLevenshteinDistance(string s, string t)
Source
Computes the Levenshtein distance between two strings using a dynamic programming approach.
sThe first string to compare.tThe second string to compare.The number of single-character edits (insertions, deletions, or substitutions) required to change one string into the other.