Show / Hide Table of Contents

Class CommandsApp

Builder for creating and running a CommandsFramework application with simplified DI setup.

Inheritance
object
CommandsApp
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: Benday.CommandsFramework
Assembly: Benday.CommandsFramework.dll
Syntax
public class CommandsApp

Methods

| Edit this page View Source

ConfigureConfiguration(Action<IConfigurationBuilder>)

Configures the configuration builder directly, allowing you to add custom configuration sources such as in-memory collections, additional JSON files, or any other IConfigurationSource. Call WithAppSettings() or WithConfigFile() before this method to initialize the configuration builder, or this method will create one.

Declaration
public CommandsApp ConfigureConfiguration(Action<IConfigurationBuilder> configure)
Parameters
Type Name Description
Action<IConfigurationBuilder> configure
Returns
Type Description
CommandsApp
| Edit this page View Source

ConfigureOptions(Action<DefaultProgramOptions>)

Configures the program options directly.

Declaration
public CommandsApp ConfigureOptions(Action<DefaultProgramOptions> configure)
Parameters
Type Name Description
Action<DefaultProgramOptions> configure
Returns
Type Description
CommandsApp
| Edit this page View Source

ConfigureServices(Action<IServiceCollection, IConfiguration>)

Configures the service collection with access to configuration. Call WithAppSettings() or WithConfigFile() before this method.

Declaration
public CommandsApp ConfigureServices(Action<IServiceCollection, IConfiguration> configure)
Parameters
Type Name Description
Action<IServiceCollection, IConfiguration> configure
Returns
Type Description
CommandsApp
| Edit this page View Source

ConfigureServices(Action<IServiceCollection>)

Configures the service collection for dependency injection.

Declaration
public CommandsApp ConfigureServices(Action<IServiceCollection> configure)
Parameters
Type Name Description
Action<IServiceCollection> configure
Returns
Type Description
CommandsApp
| Edit this page View Source

ConfigureUsageDisplay(Action<DisplayUsageOptions>)

Configures how usage information is displayed.

Declaration
public CommandsApp ConfigureUsageDisplay(Action<DisplayUsageOptions> configure)
Parameters
Type Name Description
Action<DisplayUsageOptions> configure
Returns
Type Description
CommandsApp
| Edit this page View Source

Create(string[], Assembly)

Creates a new CommandsApp builder using the specified assembly for command discovery.

Declaration
public static CommandsApp Create(string[] args, Assembly commandsAssembly)
Parameters
Type Name Description
string[] args

Command line arguments

Assembly commandsAssembly

Assembly containing command implementations

Returns
Type Description
CommandsApp

A CommandsApp builder instance

| Edit this page View Source

Create<TCommand>(string[])

Creates a new CommandsApp builder. The assembly containing the command type T will be used to discover available commands.

Declaration
public static CommandsApp Create<TCommand>(string[] args) where TCommand : class
Parameters
Type Name Description
string[] args

Command line arguments

Returns
Type Description
CommandsApp

A CommandsApp builder instance

Type Parameters
Name Description
TCommand

Any command type from the assembly containing your commands

| Edit this page View Source

Run()

Builds and runs the application synchronously.

Declaration
public void Run()
| Edit this page View Source

RunAsync()

Builds and runs the application asynchronously.

Declaration
public Task RunAsync()
Returns
Type Description
Task
| Edit this page View Source

UsesConfiguration(bool)

Sets whether the application uses the built-in configuration storage.

Declaration
public CommandsApp UsesConfiguration(bool usesConfiguration)
Parameters
Type Name Description
bool usesConfiguration
Returns
Type Description
CommandsApp
| Edit this page View Source

WithAppInfo(string, string)

Sets the application name and website.

Declaration
public CommandsApp WithAppInfo(string applicationName, string website)
Parameters
Type Name Description
string applicationName
string website
Returns
Type Description
CommandsApp
| Edit this page View Source

WithAppInfo(string, string, string)

Sets the application name, version, and website.

Declaration
public CommandsApp WithAppInfo(string applicationName, string version, string website)
Parameters
Type Name Description
string applicationName
string version
string website
Returns
Type Description
CommandsApp
| Edit this page View Source

WithAppSettings(bool)

Loads configuration from appsettings.json in the assembly's directory. Also loads environment variables.

Declaration
public CommandsApp WithAppSettings(bool optional = false)
Parameters
Type Name Description
bool optional
Returns
Type Description
CommandsApp
| Edit this page View Source

WithConfigFile(string, bool)

Loads configuration from a custom JSON file in the assembly's directory.

Declaration
public CommandsApp WithConfigFile(string filename, bool optional = false)
Parameters
Type Name Description
string filename
bool optional
Returns
Type Description
CommandsApp
| Edit this page View Source

WithEnvironmentVariables()

Adds environment variables to the configuration.

Declaration
public CommandsApp WithEnvironmentVariables()
Returns
Type Description
CommandsApp
| Edit this page View Source

WithVersion(string)

Sets the application version string.

Declaration
public CommandsApp WithVersion(string version)
Parameters
Type Name Description
string version
Returns
Type Description
CommandsApp
| Edit this page View Source

WithVersionFromAssembly()

Automatically sets the version from the entry assembly's file version.

Declaration
public CommandsApp WithVersionFromAssembly()
Returns
Type Description
CommandsApp
  • Edit this page
  • View Source
In this article
Back to top Copyright © www.benday.com | info@benday.com