Devlead.Console
2024.12.20.9
Prefix Reserved
See the version list below for details.
dotnet add package Devlead.Console --version 2024.12.20.9
NuGet\Install-Package Devlead.Console -Version 2024.12.20.9
<PackageReference Include="Devlead.Console" Version="2024.12.20.9" />
paket add Devlead.Console --version 2024.12.20.9
#r "nuget: Devlead.Console, 2024.12.20.9"
// Install Devlead.Console as a Cake Addin #addin nuget:?package=Devlead.Console&version=2024.12.20.9 // Install Devlead.Console as a Cake Tool #tool nuget:?package=Devlead.Console&version=2024.12.20.9
Devlead.Console
Devlead.Console is a streamlined NuGet source package designed to accelerate the development of .NET console applications. By providing out-of-the-box configurations for Inversion of Control (IoC), command-line parsing, logging, and other essential utilities, Devlead.Console allows developers to focus on building business logic rather than setting up foundational components.
Features
- Dependency injection / IoC container via Microsoft.Extensions
- Command-line parsing via Spectre.Console
- Logging via Microsoft.Extensions.Logging.Console
- Configuration via Microsoft.Extensions.Configuration
- Source-link for GitHub
- ...
Installation
dotnet add package Devlead.Console
Usage Example
Here's how to create a console application using Devlead.Console, which comes with sensible defaults to streamline your setup. Additionally, you can utilize optional partial methods to tailor the project to your specific needs:
public partial class Program
{
// Configure in-memory settings (useful for development/testing)
static partial void ConfigureInMemory(IDictionary<string, string?> configData)
{
configData.Add("TestService__Version", "1.0.0.0");
}
// Register your services
static partial void AddServices(IServiceCollection services)
{
services
.AddOptions<TestServiceSettings>()
.BindConfiguration(nameof(TestService));
services.AddSingleton<TestService>();
}
// Configure commands
static partial void ConfigureApp((IServiceCollection services, IConfigurator configuration) serviceConfig)
{
// Add a root level command
serviceConfig
.AddCommand<TestCommand>("test")
.WithDescription("Example test command.")
.WithExample(["test"]);
// Add nested commands using branches
serviceConfig
.AddBranch(
"yolo",
c => c.AddCommand<TestCommand>("test")
.WithDescription("Example test command.")
.WithExample(["yolo", "test"])
);
}
}
This example demonstrates:
- Setting up configuration values in memory for development
- Registering services with dependency injection
- Creating commands at both root and nested levels
- Adding command descriptions and usage examples
The resulting CLI will support commands like:
myapp test
myapp yolo test
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. |
-
net8.0
- Microsoft.Extensions.Configuration.EnvironmentVariables (>= 9.0.0)
- Microsoft.Extensions.Logging (>= 9.0.0)
- Microsoft.Extensions.Logging.Console (>= 9.0.0)
- Spectre.Console.Cli (>= 0.49.1)
- Spectre.Console.Cli.Extensions.DependencyInjection (>= 0.3.0)
- System.Linq.Async (>= 6.0.1)
-
net9.0
- Microsoft.Extensions.Configuration.EnvironmentVariables (>= 9.0.0)
- Microsoft.Extensions.Logging (>= 9.0.0)
- Microsoft.Extensions.Logging.Console (>= 9.0.0)
- Spectre.Console.Cli (>= 0.49.1)
- Spectre.Console.Cli.Extensions.DependencyInjection (>= 0.3.0)
- System.Linq.Async (>= 6.0.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
2024.12.20.13 | 61 | 12/20/2024 |
2024.12.20.11 | 59 | 12/20/2024 |
2024.12.20.9 | 63 | 12/20/2024 |
2024.12.19.5 | 69 | 12/19/2024 |
2024.12.19.2 | 58 | 12/19/2024 |