示例#1
0
        private static int Main()
        {
            string debug = Environment.GetEnvironmentVariable($"MultiRepoDebug");

            if (string.Equals(debug, "true", StringComparison.OrdinalIgnoreCase))
            {
                Trace.Listeners.Add(new TextWriterTraceListener(Console.Out));
                Trace.AutoFlush = true;
                DebugOutput.Enable();
            }

            var program = new Program
            {
                HelpBuilder = new DefaultColorHelpBuilder("help", "h"),
            };
            Assembly core   = Assembly.Load("Core");
            Assembly vcsGit = Assembly.Load("Vcs.Git");

            program.ScanAssembliesForCommands(core, vcsGit);
#if DEBUG
            string promptArgs = Environment.GetEnvironmentVariable("PromptArgs");
            if (string.Equals(promptArgs, "true", StringComparison.OrdinalIgnoreCase))
            {
                string args = Prompt($"Enter input: {Magenta}{program.Name} {Reset}");
                return(program.Run(Parser.Tokenize(args)));
            }
            else
            {
                return(program.RunWithCommandLineArgs());
            }
#else
            return(program.RunWithCommandLineArgs());
#endif
        }
示例#2
0
        private static void Main()
        {
            Trace.Listeners.Add(new TextWriterTraceListener(Console.Out));
            DebugOutput.Enable();

            int selectedItem = 0;

            while (true)
            {
                try
                {
                    Console.Clear();

                    PrintLine($"What do you want to test?");

                    string[] menuItems = MenuItems.Values.ToArray();
                    selectedItem = SelectSingle(menuItems, startingIndex: selectedItem);

                    Type[] testTypes    = MenuItems.Keys.ToArray();
                    Type   selectedType = testTypes[selectedItem];
                    if (selectedType == typeof(Program))
                    {
                        Environment.Exit(0);
                    }

                    PrintBlank();

                    var testHarness = (TestBase)Activator.CreateInstance(selectedType);
                    testHarness.Run();
                }
                catch (TargetInvocationException ex) when(ex.InnerException != null)
                {
                    PrintLine($"{Red.BgWhite}[{ex.InnerException.GetType().Name}]{ex.InnerException.Message}");
                    PrintLine($"{Magenta.BgWhite}{ex.InnerException.StackTrace}");
                }
                catch (Exception ex)
                {
                    PrintLine($"{Red.BgWhite}[{ex.GetType().Name}]{ex.Message}");
                    PrintLine($"{Magenta.BgWhite}{ex.StackTrace}");
                }

                PrintBlank();
                PrintLine($"{Black.BgYellow}Press ANY key to continue...");
                WaitForAnyKey();
            }
        }