Action
:
[ Action ]
public static void Method(...)...
[ Action ]
public static void Method(
[ Required ] string name,
[ Optional ( true )] bool flag)...
Main
method:
public static void Main( params string [] args) {
Consolery .Run( typeof ( Program ), args);
}
Run
method, you must pass the type that contains our method marked with the Action
attribute, as well as the arguments.
using System;
using NConsoler;
public class Program {
public static void Main( params string [] args) {
Consolery .Run( typeof ( Program ), args);
}
[ Action ]
public static void Method(
[ Required ] string name,
[ Optional ( true )] bool flag) {
Console .WriteLine( "name: {0}, flag: {1}" , name, flag);
}
}
> program.exe "Max"
name: Max, flag: true
> program.exe "Max" / -flag
name: Max, flag: false
Source: https://habr.com/ru/post/38896/