/// <inheritdoc /> public void StartPrompt(string[] args) { _logger.LogInformation("Starting Prompt"); _consoleWriter.WriteLine("Neo-Sharp", ConsoleOutputStyle.Prompt); if (args != null) { // Append arguments as inputs _consoleReader.AppendInputs(args.Where(u => !u.StartsWith("#")).ToArray()); } _blockchain.InitializeBlockchain().Wait(); while (!_exit) { // Read log buffer while (_logs.TryTake(out var log)) { _consoleWriter.WriteLine ( "[" + log.Level + (string.IsNullOrEmpty(log.Category) ? "" : "-" + log.Category) + "] " + log.MessageWithError, _logStyle[log.Level] ); } // Read input var fullCmd = _consoleReader.ReadFromConsole(_commandAutocompleteCache); if (string.IsNullOrWhiteSpace(fullCmd)) { continue; } fullCmd = _variables.Replace(fullCmd); _logger.LogInformation("Execute: " + fullCmd); Execute(fullCmd); } _consoleWriter.WriteLine("Exiting", ConsoleOutputStyle.Information); }
/// <inheritdoc /> public void StartPrompt(string[] args) { // Backup shell style var cb = Console.BackgroundColor; var cf = Console.ForegroundColor; // Black background _consoleHandler.ApplyStyle(ConsoleOutputStyle.Prompt); _consoleHandler.Clear(); // Start prompt _logger.LogInformation("Starting Prompt"); _consoleHandler.WriteLine("Neo-Sharp", ConsoleOutputStyle.Prompt); if (args != null) { var easyAccess = new Dictionary <string, string[]>() { { "-i", new string[] { "network start" } }, { "-s", new string[] { "network start", "log off" } }, { "-r", new string[] { "rpc start" } }, }; // Append arguments as inputs foreach (var arg in args.Where(u => !u.StartsWith("#"))) { if (easyAccess.TryGetValue(arg, out var newArgs)) { _consoleHandler.AppendInputs(newArgs); } else { _consoleHandler.AppendInputs(arg); } } } _blockchain.InitializeBlockchain().Wait(); while (!_exit) { // Read log buffer while (_logs.TryTake(out var log)) { _consoleHandler.WriteLine ( "[" + log.Level + (string.IsNullOrEmpty(log.Category) ? "" : "-" + log.Category) + "] " + log.MessageWithError, _logStyle[log.Level] ); } // Read input var fullCmd = _consoleHandler.ReadFromConsole(_commandAutocompleteCache); if (string.IsNullOrWhiteSpace(fullCmd)) { continue; } fullCmd = _variables.Replace(fullCmd); _logger.LogInformation("Execute: " + fullCmd); Execute(fullCmd); } _consoleHandler.WriteLine("Exiting", ConsoleOutputStyle.Information); // Restore shell style Console.BackgroundColor = cb; Console.ForegroundColor = cf; _consoleHandler.Clear(); }