コード例 #1
0
ファイル: Program.cs プロジェクト: kjelliverb/condep-cli
        private static void ExecuteCommand(string[] args)
        {
            var helpWriter = new CmdHelpWriter(System.Console.Out);

            try
            {
                _handler = CmdFactory.Resolve(args);
                _handler.Execute(helpWriter);
            }
            catch (AggregateException aggEx)
            {
                foreach (var ex in aggEx.InnerExceptions)
                {
                    System.Console.ForegroundColor = ConsoleColor.Red;
                    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;
                helpWriter.WriteException(ex);
                System.Console.ResetColor();
                System.Console.WriteLine("For help type ConDep Help <command>");
                Environment.Exit(1);
            }
        }
コード例 #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);
            }
        }