Ejemplo n.º 1
0
        private static void ExecuteCommand(string[] args)
        {
            var helpWriter = new CmdHelpWriter(Console.Out);

            try
            {
                _handler = CmdFactory.Resolve(args);
                _handler.Execute(helpWriter);
            }
            catch (AggregateException aggEx)
            {
                foreach (var ex in aggEx.InnerExceptions)
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    helpWriter.WriteException(ex);
                    Console.ResetColor();
                    Console.WriteLine("For help type ConDep Help <command>");
                }
                Environment.Exit(1);
            }
            catch (Exception ex)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                helpWriter.WriteException(ex);
                Console.ResetColor();
                Console.WriteLine("For help type ConDep Help <command>");
                Environment.Exit(1);
            }
        }
Ejemplo n.º 2
0
        private static void ExecuteCommand(string[] args)
        {
            CmdHelpWriter helpWriter = null;

            try
            {
                _handler   = CmdFactory.Resolve(args);
                helpWriter = _handler.HelpWriter;
                _handler.Execute(helpWriter);
            }
            catch (AggregateException aggEx)
            {
                foreach (var ex in aggEx.InnerExceptions)
                {
                    System.Console.ForegroundColor = ConsoleColor.Red;
                    if (helpWriter == null)
                    {
                        helpWriter = new CmdHelpWriter(System.Console.Out);
                    }
                    helpWriter.WriteException(ex);
                    System.Console.ResetColor();
                    System.Console.WriteLine("For help type ConDep Help <command>");
                }
                Environment.Exit(1);
            }
            catch (Exception ex)
            {
                System.Console.ForegroundColor = ConsoleColor.Red;
                if (helpWriter == null)
                {
                    helpWriter = new CmdHelpWriter(System.Console.Out);
                }
                helpWriter.WriteException(ex);
                System.Console.ResetColor();
                System.Console.WriteLine("For help type ConDep Help <command>");
                Environment.Exit(1);
            }
        }