public static T ParseAndHandleArguments <T>(string Message, string[] args, bool ignoreError = false) where T : new() { if (args.Length == 1 && args.First() == "--build") { TaskBuilder.BuildSelf(); Environment.Exit(0); } if (args.Length > 1 && args.First() == "--publish") { TaskBuilder.PublishSelf(args).Wait(); Environment.Exit(0); } Console.WriteLine(string.Join(" ", args)); args = MoveBoolsLast(args); Console.WriteLine(Message); if (Environment.GetEnvironmentVariable("SYSTEM_DEBUG") == "true") { Console.WriteLine(string.Join(" ", args)); } // var options = new T(); var b = new CommandLine.Parser((s) => { s.IgnoreUnknownArguments = true; }); var result = RunParseAndHandleArguments <T>(b, args); if (result != null || ignoreError) { return(result); } throw new ArgumentException("Arguments not working " + string.Join(" ", args)); }