/// <summary> /// /// </summary> /// <param name="args"></param> static protected void Run(string[] args) { Thread.CurrentThread.Name = "NativeHost::Main"; try { SetConsoleCtrlHandler(new HandlerRoutine(ConsoleCtrlHandler), true); regService = new RegistryService(endpoint.Properties); BrowserType caller = endpoint.CheckBrowserCall(args); if (caller == BrowserType.Unknown) { Log.Debug("Native host started with args {0} ", args); Parser parser = new CommandLine.Parser(with => with.HelpWriter = null); parserResult = parser.ParseArguments <Options>(args); parser.Dispose(); parserResult .WithParsed(options => RunAndReturnExitCode(options)) .WithNotParsed(errors => DisplayHelp(errors)); } else { Log.Debug("Native host called by {1} with args {0} ", args, caller); DoHostListen(caller); } } catch (Exception e) { Log.Fatal(e.Message); } Log.CloseAndFlush(); Log.Debug("Native host will now exit"); }
public void TaskWithTagAndTagIntersectThrowAnExcption() { var commandLineParser = new CommandLine.Parser(); CommandLineParser parserObj = new CommandLineParser(new OptionConverter(new JsonDeserializer()), commandLineParser, new ParserUsage(), new VerbFormater()); string[] argv = new string[] { "task info", "--tags", "t1", "t2", "--exclusive-tags", "t3", "t4" }; ParseException ex = null; var converter = new OptionConverter(null); var usage = new ParserUsage(); var parser = commandLineParser.ParseArguments <Options.InfoTaskOptions>(argv); ex = Assert.Throws <ParseException>(() => parser.MapResult( (Options.InfoTaskOptions o) => converter.ConvertGenericGetterOption(ConfigType.Task, CommandApi.Info, o), err => throw new ParseException(usage.PrintHelp(parser, err, argv)))); Assert.IsNotNull(ex); commandLineParser.Dispose(); }
static void Main(string[] args) { options = new CliOptions(); var parser = new Parser (s => { s.MutuallyExclusive = true; s.CaseSensitive = true; s.HelpWriter = Console.Error; }); cout = new ConsoleOutput(); if (parser.ParseArguments(args, options)) { // console output setup cout.Debug = options.debug; cout.Verbose = options.verbose; // file output setup directory = options.filepath; fileName = options.filename; XMLfilename = Path.Combine(directory, fileName + ".xml"); // if we are creating a new setup, try to find online servers // and save the XML if (options.create) { DiscoverServers(); SaveXML(); } // else, try to load the XML file from location else if (LoadXML()) { if (options.calibrate) { RunCalibration(); } else if (options.showIndices) { ShowDisplayIndices(); } else if (options.hideIndices) { HideDisplayIndices(); } } } parser.Dispose(); cout.DebugWaitForInput(); }