Esempio n. 1
0
 private void Run(string[] args)
 {
     if (Debugger.IsAttached)
     {
         try {
             Console.BufferWidth = Console.WindowWidth = 80;
         }
         catch { }
     }
     try {
         Console.OutputEncoding = Encoding.UTF8;
         var result = new Parser(s => s.HelpWriter = null).ParseArguments(args, OptionsTypes);
         result
         .WithNotParsed(InvokeError)
         .WithParsed <ListOptions>(InvokeList)
         .WithParsed <StartOptions>(InvokeStart)
         .WithParsed <HelpOptions>(InvokeHelp);
     }
     catch (Exception ex) {
         HelpView.Message(ErrorInfo.Exception(ex)).Render();
     }
     finally {
         if (Debugger.IsAttached)
         {
             View.PressEnter().Render();
             Console.ReadLine();
         }
     }
 }
Esempio n. 2
0
 private void Run(string[] args)
 {
     if (Debugger.IsAttached)
     {
         try {
             Console.BufferWidth = Console.WindowWidth = 80;
         }
         catch { }
     }
     try {
         Console.OutputEncoding = Encoding.UTF8;
         var options = new RootOptions();
         var parser  = new Parser(s => s.HelpWriter = null);
         if (!parser.ParseArguments(args, options, (s, v) => { }))
         {
             InvokeError(options);
         }
         else if (options.List != null)
         {
             InvokeList(options.List);
         }
         else if (options.Start != null)
         {
             InvokeStart(options.Start);
         }
         else
         {
             InvokeHelp(options.Help);
         }
     }
     catch (Exception ex) {
         HelpView.Message(ErrorInfo.Exception(ex)).Render();
     }
     finally {
         if (Debugger.IsAttached)
         {
             View.PressEnter().Render();
             Console.ReadLine();
         }
     }
 }