-
Notifications
You must be signed in to change notification settings - Fork 2
Home
Roger Knapp edited this page Mar 10, 2014
·
2 revisions
CSharpTest.Net.Commands
Quick-start Example:
using System;
using CSharpTest.Net.Commands;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
try
{
new CommandInterpreter(DefaultCommands.Default, typeof(Commands))
.Run(args);
}
catch (ApplicationException ae)
{
Console.Error.WriteLine(ae.Message);
Environment.Exit(1);
}
catch (Exception ex)
{
Console.Error.WriteLine(ex);
Environment.Exit(2);
}
}
}
static partial class Commands
{
public static void Hello()
{
Console.WriteLine("Greetings");
}
}
}
Optionally, the command methods can also be decorated to provide additional information:
static partial class Commands
{
[Command("hello-world", Description = "A simple example.")]
public static void Hello(
[Argument(DisplayName = "user-name", Description = "Personalize greeting", DefaultValue = null)] string userName
)
{
Console.WriteLine("Greetings {0}", userName);
}
}