Esempio n. 1
0
        public static void Main()
        {
            var commandManager = new ConsoleCommandManager();

            commandManager.LoadCommands(typeof(Program), null);
            commandManager.AddHelpCommand();

            s_shouldRun = true;
            while (s_shouldRun)
            {
                try
                {
                    s_logger.Write($"{Environment.CurrentDirectory}> ");
                    commandManager.Execute(s_logger.ReadLine());
                }
                catch (NonExistentCommandException ex)
                {
                    s_logger.LogError("Unexistent command '{0}'. Use the 'help' command to list all commands.", ex.Command);
                }
                catch (CommandInvocationException ex)
                {
                    s_logger.LogError("Error while executing '{0}': {1}\n{2}", ex.Command, ex.Message, ex.StackTrace !);
                }
            }
        }
Esempio n. 2
0
 public override void Write(char value) => _logger.Write(value);