以下のデフォルト機能は、実行時に実行されませんが、実行すると実行さmyExe.exe
れますmyExe.exe -launch
。このアプリケーションがデフォルトで実行されない理由について何か考えはありますか? ドキュメントによると、これはうまくいくはずです
ドキュメントからの抜粋:
As a fallback, a default handler may be registered which will handle all arguments which are not handled by any of the above matching algorithms. The default handler is designated by the name <> (which may be an alias for another named NDesk.Options.Option).
私のコード:
public static void Main (string[] args)
{
bool showHelp = false;
var options = new OptionSet() {
{
"h", "Show help",
v => showHelp = true
}, {
"config", "Reconfigure the launcher with different settings",
v => PromptConfig()
}, {
"v", "Show current version",
v => ShowVersion()
}, {
"launch",
v => LaunchApplication()
}, {
"<>", //default
v => LaunchApplication()
}
};
//handle arguments
List<string> extra;
try {
extra = options.Parse (args);
}
catch (OptionException e) {
Console.Write("MyApp:");
Console.WriteLine(e.Message);
Console.WriteLine("Try `MyApp--help' for more information");
return;
}
if (showHelp) {
ShowHelp(options);
return;
}
}