Example #1
0
        static void Main(string[] args)
        {
            var options = new CLOptions();

            Console.WriteLine(GetGilesFunnyLine());

            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;

            var parser = new CommandLineParser(
                new CommandLineParserSettings(false, Console.Error));

            if (!parser.ParseArguments(args, options))
            {
                Console.WriteLine("Unable to determine what command lines arguments were used, check the help above!\nThe minimum needed is the -s [solution file path].");
                Environment.Exit(1);
            }

            config = GetGilesConfigFor(options);

            kernel = new StandardKernel(new SlayerModule(config));

            ConsoleSetup();

            sourceWatcher = StartSourceWatcher();

            menuOptions = GetInteractiveMenuOptions();

            DisplayInteractiveMenuOptions();

            MainFeedbackLoop();
        }
Example #2
0
        static GilesConfig GetGilesConfigFor(CLOptions options)
        {
            var solutionPath     = options.SolutionPath.Replace("\"", string.Empty);
            var testAssemblyPath = GetTestAssemblyPath(options);

            solutionPath     = Path.GetFullPath(solutionPath);
            testAssemblyPath = Path.GetFullPath(testAssemblyPath);

            return(SetupGilesConfig(solutionPath, testAssemblyPath));
        }
Example #3
0
        static GilesConfig GetGilesConfigFor(CLOptions options)
        {
            var solutionPath   = options.SolutionPath.Replace("\"", string.Empty);
            var testAssemblies = GetTestAssemblies(options);

            solutionPath = Path.GetFullPath(solutionPath);
            for (var i = 0; i < testAssemblies.Count() - 1; i++)
            {
                testAssemblies[i] = Path.GetFullPath(testAssemblies[i]);
            }

            return(SetupGilesConfig(solutionPath, testAssemblies));
        }
Example #4
0
        private static string GetTestAssemblyPath(CLOptions options)
        {
            var path = options.TestAssemblyPath != null
                ? options.TestAssemblyPath.Replace("\"", string.Empty)
                : FindTestAssembly(options.SolutionPath);

            if (path == null)
            {
                Console.Error.Write(options.GetUsage());
                Console.Error.WriteLine("No test assemblies detected. Please specify"
                                        + " the TestAssemblyPath command line option.");
                Console.Error.WriteLine();
                Environment.Exit(1);
            }
            return(path);
        }
Example #5
0
        static List <string> GetTestAssemblies(CLOptions options)
        {
            var testAssemblies = options.GetTestAssemblies();

            testAssemblies = testAssemblies.Count > 0 ?
                             testAssemblies :
                             FindTestAssembly(options.SolutionPath);

            if (testAssemblies == null)
            {
                Console.Error.Write(options.GetUsage());
                Console.Error.WriteLine("No test assemblies detected. Please specify"
                                        + " the TestAssemblyPaths command line option.");
                Console.Error.WriteLine();
                Environment.Exit(1);
            }
            return(testAssemblies);
        }
Example #6
0
        static void Main(string[] args)
        {
            var options = new CLOptions();

            var parser = new CommandLineParser(
                new CommandLineParserSettings(false, Console.Error));

            if (!parser.ParseArguments(args, options))
            {
                Environment.Exit(1);
            }

            Console.Clear();
            Console.CancelKeyPress += Console_CancelKeyPress;
            Console.WriteLine("Giles - your own personal watcher");

            var solutionPath     = options.SolutionPath;
            var testAssemblyPath = options.TestAssemblyPath;
            var projectRoot      = options.ProjectRoot;

            var kernel = new StandardKernel(new SlayerModule(solutionPath, testAssemblyPath, projectRoot));

            var configFactory = kernel.Get <GilesConfigFactory>();

            config = configFactory.Build();

            sourceWatcher = kernel.Get <SourceWatcher>();

            sourceWatcher.Watch(solutionPath, @"*.cs");

            DisplayOptions();

            MainFeedbackLoop();

            Console.WriteLine("See you next time...");
        }
Example #7
0
 protected static void SetupOptions()
 {
     options = new CLOptions();
     parser  = new CommandLineParser(new CommandLineParserSettings(false));
     parser.ParseArguments(commandLineArgs, options);
 }
Example #8
0
        private static void runMainLoop(CLOptions options)
        {
            switch (options.LogMode)
            {
            case "console":
                _logger = App.ConsoleLogger;
                break;

            case "both":
                _logger = App.FileAndConsoleLogger;
                break;

            case "file":
            default:
                _logger         = App.FileLogger;
                options.LogMode = LogMode.File;
                break;
            }

            _app = new App(App.DefaultPathsProvider, _logger);

            _options = options;

            if (options.ListeningPort > 0)
            {
                _app.Listen(options.ListeningPort);
            }

            _app.ConnectToPeers();

            if (_app.IsInIbd)
            {
                ensureLogToConsole(App.LogLevel.Info, "Initial block download is running...");

                Console.Out.Flush();

                while (_app.IsInIbd)
                {
                    Thread.Sleep(100);
                }

                if (_app.Daemon.CurrentIbdPhase == InitialBlockDownload.Phase.Succeeded)
                {
                    ensureLogToConsole(App.LogLevel.Info, "Initial block download is finished.");
                    ensureLogToConsole(App.LogLevel.Info, $"Current height: {_app.ChainManager.Height}");
                }
                else
                {
                    ensureLogToConsole(App.LogLevel.Info, "Initial block download failed. Exitting...");

                    return;
                }
            }

            Console.CancelKeyPress += onSigInt;

            var token = _app.CancellationTokenSource.Token;

            if (options.IsNode)
            {
                while (!token.IsCancellationRequested)
                {
                    Thread.Sleep(500);
                }
            }
            else
            {
                Console.WriteLine("Welcome to ameow-cli. Enter `help` to show help message.");
                Console.WriteLine();

                var inputSeparator = new string[] { " " };
                while (!token.IsCancellationRequested)
                {
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.Write(">>> ");
                    string input = Console.ReadLine();
                    Console.ForegroundColor = ConsoleColor.Gray;

                    if (input == null)
                    {
                        Thread.Sleep(100);
                        if (token.IsCancellationRequested)
                        {
                            break;
                        }
                    }

                    string[] args = input.Split(inputSeparator, StringSplitOptions.RemoveEmptyEntries);
                    if (args.Length == 0)
                    {
                        continue;
                    }

                    string  cmdName = args[0];
                    Command cmd     = commands.Find(c => c.Name == cmdName);
                    if (cmd != null)
                    {
                        cmd.Handler(args);
                    }
                    else
                    {
                        cmd_help(args);
                    }
                }
            }

            try
            {
                _app.Shutdown();
            }
            catch (Exception ex)
            {
                _app.Logger.Log(App.LogLevel.Error, string.Format("Cannot shutdown properly: {0}", ex.Message));
            }
        }
Example #9
0
 private static void run(CLOptions options)
 {
     runMainLoop(options);
 }