public void ReadCommands(IWriter writer, IInterpreter interpreter)
        {
            string input = Console.ReadLine();

            while (input.ToLower() != exitCommand.ToLower())
            {
                string[] data = input
                                .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

                string commandName = default(string);

                try
                {
                    commandName = data[0].ToLower();
                }
                catch (Exception)
                {
                    writer.WriteLine("Invalid command!");
                    this.ReadCommands(writer, interpreter);
                    return;
                }

                interpreter.InterpretCommand(writer, commandName, input, data);

                input = Console.ReadLine();
            }
        }
Example #2
0
        public void StartReadingCommands()
        {
            OutputWriter.WriteMessage($"{SessionData.CurrentPath}> ");
            var input = Console.ReadLine();

            while (input != null && input.ToLower() != EndCommand)
            {
                var inputCommand = input.Trim().ToLower();
                interpreter.InterpretCommand(inputCommand);

                OutputWriter.WriteEmptyLine();
                OutputWriter.WriteMessage($"{SessionData.CurrentPath}> ");
                input = Console.ReadLine();
            }
        }
Example #3
0
        public void StartReadingCommands()
        {
            OutputWriter.WriteMessage($"{SessionData.currentPath}> ");
            string input = Console.ReadLine();

            input = input.Trim();

            while (input != endCommand)
            {
                interpreter.InterpretCommand(input);
                OutputWriter.WriteMessage($"{SessionData.currentPath}> ");
                input = Console.ReadLine();
                input = input.Trim();
            }
        }
Example #4
0
 public void Run()
 {
     while (true)
     {
         try
         {
             string input  = Console.ReadLine();
             string result = interpreter.InterpretCommand(input);
             Console.WriteLine(result);
         }
         catch (Exception e)
         {
             Console.WriteLine(e.Message);
         }
     }
 }