Devlead.Console 2024.12.20.9

Prefix Reserved
There is a newer version of this package available.
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                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Devlead.Console" Version="2024.12.20.9" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Devlead.Console --version 2024.12.20.9                
#r "nuget: Devlead.Console, 2024.12.20.9"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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