Class CommandsApp
Builder for creating and running a CommandsFramework application with simplified DI setup.
Assembly: Benday.CommandsFramework.dll
Syntax
Methods
|
Edit this page
View Source
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
Returns
|
Edit this page
View Source
Configures the program options directly.
Declaration
public CommandsApp ConfigureOptions(Action<DefaultProgramOptions> configure)
Parameters
Returns
|
Edit this page
View Source
Configures the service collection with access to configuration.
Call WithAppSettings() or WithConfigFile() before this method.
Declaration
public CommandsApp ConfigureServices(Action<IServiceCollection, IConfiguration> configure)
Parameters
Returns
|
Edit this page
View Source
Configures the service collection for dependency injection.
Declaration
public CommandsApp ConfigureServices(Action<IServiceCollection> configure)
Parameters
Returns
|
Edit this page
View Source
Configures how usage information is displayed.
Declaration
public CommandsApp ConfigureUsageDisplay(Action<DisplayUsageOptions> configure)
Parameters
Returns
|
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
|
Edit this page
View Source
RunAsync()
Builds and runs the application asynchronously.
Declaration
Returns
|
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
|
Edit this page
View Source
WithAppInfo(string, string)
Sets the application name and website.
Declaration
public CommandsApp WithAppInfo(string applicationName, string website)
Parameters
Returns
|
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
Returns
|
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
|
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
|
Edit this page
View Source
WithEnvironmentVariables()
Adds environment variables to the configuration.
Declaration
public CommandsApp WithEnvironmentVariables()
Returns
|
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
|
Edit this page
View Source
WithVersionFromAssembly()
Automatically sets the version from the entry assembly's file version.
Declaration
public CommandsApp WithVersionFromAssembly()
Returns