Parameters Passed to Command Line

NConsoler has two types of parameters:

  • Required (always go before optional in command line as well as declared in action method)
  • Optional (is not necessary and could be skipped in command line)

Form of optional parameter is next: /param_name:param_value where param_name - name of parameter in source code.

NConsoler provides aliases to optional parameters. For example if parameter name is flag, and you want to use it in command line as /f, you can specify one or more aliases in OptionalAttribute arguments.

Boolean optional parameters are used without param value: /param_name or /-param_name in first case true will be sent to the method and false in second one. Parameters /?, /help and /h are reserved for requesting help.

NConsoler supports next types of parameters:

  • string
  • int
  • bool
  • string[]
  • int[]
  • DateTime

Example:


[Action]
public static void Method(
    [Required]
    string p1,
    [Required]
    int p2,
    [Required]
    string[] p3,
    [Required]
    int[] p4,
    [Required]
    DateTime p5,
    [Optional(false)]
    bool flag)...

to run this method: program.exe "first" 2 "a"+"b" 4+5+6 20-01-2008 /flag

if you wish to add an additional parameter type you can modify NConsoler source code or just add a string parameter and parse it by yourself.