-
Notifications
You must be signed in to change notification settings - Fork 4
Home
This library can be used to make writing .NET console applications easier. Conceptually, you can think of it as routing for the command line. You can specify which methods in your application can be accessed via the command line and synoptic does the rest.
The excellent Mono.Options is used internally to do the command line parsing.
Create a console application and just reference synoptic.dll in your project:
using Synoptic;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
new CommandRunner().Run(args);
}
}
[Command]
public class MyCommand
{
[CommandAction]
public void SayHello(string message)
{
Console.WriteLine("Hello " + message);
}
}
}
Compile and run your application and you should see output similar to:
C:> ConsoleApplication1
Usage: ConsoleApplication1 COMMAND ACTION [ARGS]
The available commands are:
my-command
C:> ConsoleApplication1 my-command
The available actions for command 'my-command' are:
say-hello
message=<VALUE>
Congratulations - you have now exposed your first command via the command line! Now you can execute your first command:
C:> ConsoleApplication1 my-command say-hello --message world
Hello world
Loading commands from external types
Customizing commands
Customizing actions
Customizing action parameters
Using dependency injection
Global options
Using Console Formatter
Exception handling
Find it on NuGet: http://nuget.org/List/Packages/synoptic