EasyConsoleFramework.AutoFac 1.0.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package EasyConsoleFramework.AutoFac --version 1.0.1                
NuGet\Install-Package EasyConsoleFramework.AutoFac -Version 1.0.1                
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="EasyConsoleFramework.AutoFac" Version="1.0.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add EasyConsoleFramework.AutoFac --version 1.0.1                
#r "nuget: EasyConsoleFramework.AutoFac, 1.0.1"                
#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 EasyConsoleFramework.AutoFac as a Cake Addin
#addin nuget:?package=EasyConsoleFramework.AutoFac&version=1.0.1

// Install EasyConsoleFramework.AutoFac as a Cake Tool
#tool nuget:?package=EasyConsoleFramework.AutoFac&version=1.0.1                

Easy Console Framework NuGet NuGet

.NET Core library for easy building console application with command line parsing and inversion of control (IoC).
By default it's using Microsoft.Extensions.DependencyInjection (see configuration for AutoFac, custom).
It was designed for easy building application with multiple commands and low coupling.

How to use

  1. Install nuget package ECF
  2. Put in your program.cs this fragment:
// Program.cs
using ECF;

await new ECFHostBuilder()
    .UseDefaultCommands() // register all commands with CommandAttribute and default commands (help, exit, ...)
    .AddConfiguration(optional: true) // adds appsettings.json        
    .Configure((ctx, services, _) =>
    {
        ctx.Intro = $"This is example console application based on ECF. Version {typeof(Program).Assembly.GetName().Version}.\nType help to list available commands";
        ctx.HelpIntro = "Welcome to example program that showcases ECF framework. Enter one of command listed below";
        ctx.Prefix = "> ";
    })
    .RunAsync(args);

it will initialize and run your ECF console application

  1. You can now add your first command
using ECF;

[Command("hello-world")]
class HelloWorldCommand : CommandBase
{
    private readonly IConfiguration configuration;

    [Required, Parameter("--name", "-n", Description = "Your name")]
    public string Name { get; set; }

    public HelloWorldCommand(IConfiguration configuration)
    {
        // you can use constructor to inject services
        this.configuration = configuration;
    }

    public override void Execute()
    {
        Console.WriteLine($"Hello {Name}");
    }
}
  1. Run your program you should see welcome info
This is example console application based on ECF. Version 0.0.0.
Type help to list available commands
  1. Invoke your command in console by typing
> hello-world -n John

Template

You can use ECF template to create new projects. Firstly you need to install template:

dotnet new install ECFTemplates

Then you can create new projects using

dotnet new ecf -o MyNewProject

Examples

For some other use cases please look into Example Project.

Advanced scenarios

For more advanced scenarios please refer to this section.

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  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. 
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
1.0.3 79 10/15/2024
1.0.2 125 8/29/2024
1.0.1 120 8/13/2024
1.0.0 83 8/4/2024
0.2.3 113 7/28/2024
0.2.2 71 7/28/2024
0.2.1 155 8/29/2023
0.2.0 135 8/29/2023