Simple console application boilerplate for .NET
Available on Nuget: http://nuget.org/packages/ConsolePlate
There are many developers that use console applications for managing tasks like:
- Creating databases
- Seeding data
- Configuring environment for their projects, etc
So for every project they must create console app with ability to determine commands, parse command line args and etc. ConsolePlate boilerplate can simplify and accelerate the development of such apps. It uses MEF
to quickly plug-in commands and NDesk.Options
to parse command line arguments. So all you need is create command that implements ICommand
interface and export it to the console application project that uses ConsolePlate.
ConsolePlate is licensed under the Apache Licence, Version 2.0.
Install from NuGet:
Install-Package ConsolePlate
In your console application Main() method do as follows:
var plate = new Plate();
plate.Start(args, Assembly.GetExecutingAssembly());
This will start ConsolePlate and indicate to look commands in current assembly.
Also you can pass folder name to look commands instead of assembly.
To create command:
- Create class that implements interface ICommand
- Mark it with 'Export' attribute(from
System.ComponentModel.Composition
):Export(typeof(ICommand))
- Implement
Execute
method - Implement
Parameters
property. It would be parsed automatically. For more info about parsing command line arguments look at NDesk.Options
Look at ConsolePlate.Example project to see practical example.