/// <summary> /// パーサーのパースイベントを実行する /// </summary> /// <param name="sender">イベント呼び出し元オブジェクト</param> /// <param name="e">e</param> private static void Parser_ArgumentParsed(object sender, ArgumentParsedEventArgs e) { if (e.Argument.ArgumentName == "Help") { e.Cancel = true; } }
private static void CommandLineParser_ArgumentParsed(object sender, ArgumentParsedEventArgs e) { // When the -Help argument (or -? using its alias) is specified, parsing is immediately cancelled. That way, CommandLineParser.Parse will // return null, and the Create method will display usage even if the correct number of positional arguments was supplied. // Try it: just call the sample with "CommandLineSampleCS.exe foo bar -Help", which will print usage even though both the Source and Destination // arguments are supplied. if (e.Argument.ArgumentName == "Help") // The name is always Help even if the alias was used to specify the argument { e.Cancel = true; } }