Quick Start

Next code allows you automatically calls DoWork method with all needed parameters specified by user or to show an error. If user does not specify any parameters it shows some basic help.


using System;
using NConsoler;

class Program {
      static void Main(string[] args) {
            Consolery.Run(typeof(Program), args);
      }

      [Action]
      public static void DoWork(
            [Required]
            int count,
            [Optional(false)]
            bool flag) {
                 Console.WriteLine("DoWork {0} {1}", count, flag);
            }
}

Download NConsoler Quick Start example

To run this example Command line should be like Program.exe 10 /flag To pass false for boolean parameter, use /-flag option.

As you see, to use NConsoler you have to add using NConsoler; at the beginning of file, then specify Consolery.Run with a type which contains methods you want to execute and command line arguments from user and add a reference to NConsoler.dll library.

Method you wan to run should be public static and marked with an Action attribute. Each parameter should be marked with Required or Optional attributes. Optional attribute requires specifying default value for parameter.

All infrastructure errors (like Optional attribute with incorrect parameter type) are handled by NConsoler engine, so, to check whether you configuration is correct, just run an application without any arguments. If everything is ok, then you'll see the help message.