ECFTemplates 0.1.1
See the version list below for details.
dotnet add package ECFTemplates --version 0.1.1
NuGet\Install-Package ECFTemplates -Version 0.1.1
<PackageReference Include="ECFTemplates" Version="0.1.1" />
paket add ECFTemplates --version 0.1.1
#r "nuget: ECFTemplates, 0.1.1"
// Install ECFTemplates as a Cake Addin #addin nuget:?package=ECFTemplates&version=0.1.1 // Install ECFTemplates as a Cake Tool #tool nuget:?package=ECFTemplates&version=0.1.1
Easy Console Framework
.NET Core library for easy building console application with command line parsing and inversion of control (IoC) powered by Autofac.
It was designed for easy building application with multiple commands and low coupling.
Currently only works on Windows due to shell32.dll
dependency.
How to use
- Put in your program.cs this fragment:
// Program.cs
using ECF;
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 = ">";
})
.Run(args);
it will initialize and run your ECF console application
- You can now add your first command
using ECF;
[Command("hello-world")]
class HelloWorldCommand : CommandBase
{
private readonly IConfiguration configuration;
[Parameter(ShortName = "n", LongName = "name", 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()
{
if (Name == null)
{
DisplayHelp();
return;
}
Console.WriteLine($"Hello {Name}");
}
}
- Run your program you should see welcome info
This is example console application based on ECF. Version 0.1.0.
Type help to list available commands
- Invoke your command in console by typing
> hello-world -n John
Custom commands
By default it will initialize all commands inside current and entry assembly with [Command]
attribute. To change that you can register commands by calling RegisterCommands(params Assembly[])
method:
.Configure((ctx, services, registry) =>
{
// ...
registry.RegisterCommands<MyCommandAttribute>(typeof(Class).Assembly);
})
To remove default commands such as help
, exit
, and load-script
you need to remove this line:
.UseDefaultCommands()
and register commands manually:
.Configure((ctx, services, registry) =>
{
// ...
registry.RegisterCommands<ECF.CommandAttribute>(System.Reflection.Assembly.GetExecutingAssembly());
})
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
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. 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 was computed. 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 was computed. 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. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
This package has no dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.