Exemplo n.º 1
0
 public void StartReadingCommands()
 {
     while (true)
     {
         OutputWriter.WriteMessage($"{SessionData.currentPath}> ");
         string input = Console.ReadLine();
         input = input.Trim();
         if (input == endCommand)
         {
             break;
         }
         this.interpreter.InterpredCommand(input);
     }
 }
Exemplo n.º 2
0
        public static void StartReadingCommands()
        {
            OutputWriter.WriteMessage($"{SessionData.currentPath}> ");
            string input = Console.ReadLine();

            input = input.Trim();
            while (input != EndCommand)
            {
                CommandInterpreter.InterpredCommand(input);
                OutputWriter.WriteMessage($"{SessionData.currentPath}> ");
                input = Console.ReadLine();
                input = input.Trim();
            }
        }
Exemplo n.º 3
0
 public static void StartReadingCommands()
 {
     while (true)
     {
         OutputWriter.WriteMessage($"{SessionData.currentPath}> ");
         var input = Console.ReadLine();
         input = input.Trim();
         if (input == endCommand)
         {
             return;
         }
         CommandInterpreter.InterpredCommand(input);
     }
 }
Exemplo n.º 4
0
        public static void StartReadingCommands()
        {
            while (true)
            {
                OutputWriter.WriteMessage($"{SessionData.currentPath}> ");
                string input = Console.ReadLine();
                if (input.Equals(EndCommand))
                {
                    break;
                }

                input = input.Trim();
                CommandInterpreter.InterpretCommand(input);
            }
        }
Exemplo n.º 5
0
        public void StartReadingCommands()
        {
            OutputWriter.WriteMessage($"{SessionData.CurrentPath}>");
            string input = Console.ReadLine();

            input = input.Trim();

            while (!input.Equals(EndCommand))
            {
                this.interpreter.InterpredCommand(input);
                OutputWriter.WriteMessage($"{SessionData.CurrentPath}>");
                input = Console.ReadLine();
                input = input.Trim();
            }
        }
Exemplo n.º 6
0
        public static void StartReadingCommands()
        {
            OutputWriter.WriteMessage($"{SessionData.currentPath}> ");
            var input = Console.ReadLine();

            input = input.Trim();

            while (input != endCommand)
            {
                //Interpret comand
                OutputWriter.WriteMessage($"{SessionData.currentPath}> ");
                input = Console.ReadLine();
                input = input.Trim();
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Starts to listen for commands and executes them if the syntax is correct.
        /// </summary>
        public static void StartReadingCommands()
        {
            OutputWriter.WriteMessage($"{SessionData.currentPath}> ");
            string input = Console.ReadLine();

            input = input.Trim();

            // TODO: change with do-while ??? avoiding repetitions of code
            while (!input.Equals(endCommand))
            {
                CommandInterpreter.InterpredComman(input);
                OutputWriter.WriteMessage($"{SessionData.currentPath}> ");
                input = Console.ReadLine();
                input = input.Trim();
            }
        }
Exemplo n.º 8
0
        public static void StartReadingCommands()
        {
            bool closeConsole = false;

            while (!closeConsole)
            {
                OutputWriter.WriteMessage($"{SessionData.currentPath}>");
                string input = Console.ReadLine();
                input = input.Trim();
                if (input.Equals(endCommand))
                {
                    closeConsole = true;
                    continue;
                }
                CommandInterpreter.InterpredCommand(input);
            }
        }
Exemplo n.º 9
0
        public static void TraverseDirectory(int depth)
        {
            OutputWriter.WriteEmptyLine();
            int            initialIdentation = SessionData.currentPath.Split('\\').Length;
            Queue <string> subfolders        = new Queue <string>();

            subfolders.Enqueue(SessionData.currentPath);

            while (subfolders.Count > 0)
            {
                string currentPath = subfolders.Dequeue();

                int identation = currentPath.Split('\\').Length - initialIdentation;

                OutputWriter.WriteMessage(new string('-', identation));
                OutputWriter.WriteMessage(currentPath);
                OutputWriter.WriteEmptyLine();

                string folderLength = new string('-', currentPath.Length);

                try
                {
                    foreach (var file in Directory.GetFiles(currentPath))
                    {
                        var fileName = file.Split(new[] { '\\' }, StringSplitOptions.RemoveEmptyEntries).Last().ToString();
                        OutputWriter.WriteMessageOnNewLine(folderLength + "\\" + fileName);
                    }

                    foreach (var directoryPath in Directory.GetDirectories(currentPath))
                    {
                        subfolders.Enqueue(directoryPath);
                    }
                }
                catch (UnauthorizedAccessException)
                {
                    OutputWriter.DisplayException(ExceptionMessages.UnauthorizedExceptionMessage);
                }


                if (identation == depth)
                {
                    break;
                }
            }
        }
Exemplo n.º 10
0
        public static void StartReadingCommands()
        {
            OutputWriter.WriteMessage($"{SessionData.CurrentPath}>");

            string input;

            while ((input = Console.ReadLine()) != EndCommand)
            {
                if (string.IsNullOrWhiteSpace(input))
                {
                    continue;
                }
                input = input.Trim();

                CommandInterpreter.InterpredCommand(input);
                OutputWriter.WriteMessage($"{SessionData.CurrentPath}>");
            }
        }
Exemplo n.º 11
0
 public static void StartReadingCommands()
 {
     while (true)
     {
         OutputWriter.WriteMessage($"{SessionData.currentPath}> ");
         string input = Console.ReadLine().Trim();
         if (input.Equals(endCommand))
         {
             break;
         }
         if (string.IsNullOrEmpty(input))
         {
             input = Console.ReadLine().Trim();
             continue;
         }
         CommandInterpreter.InterpredCommand(input);
     }
 }
Exemplo n.º 12
0
 public void StartReadingCommands()
 {
     // Reading commands until we receive the end "quit" command
     while (true)
     {
         OutputWriter.WriteMessage($"{SessionData.currentPath}> ");
         string input = Console.ReadLine().Trim();
         if (input.Equals(endCommand))
         {
             break;
         }
         if (string.IsNullOrEmpty(input))
         {
             input = Console.ReadLine().Trim();
             continue;
         }
         this.interpreter.InterpretCommand(input);
     }
 }
Exemplo n.º 13
0
        public static void StartReadingCommands()
        {
            OutputWriter.WriteMessage($"{SessionData.currentPath}> ");
            string input = Console.ReadLine();

            input = input.Trim();
            bool isInputQuit = false;

            while (!isInputQuit)
            {
                if (input == endCommand)
                {
                    isInputQuit = true;
                    break;
                }
                CommandInterpreter.InterpredCommand(input);
                OutputWriter.WriteMessage($"{SessionData.currentPath}> ");
                input = Console.ReadLine();
                input = input.Trim();
            }
        }
Exemplo n.º 14
0
        public static void TraverseDirectory(int depth)
        {
            OutputWriter.WriteEmptyLine();
            int            initialIdentation = SessionData.currentPath.Split('\\').Length;
            Queue <string> subFolders        = new Queue <string>();

            subFolders.Enqueue(SessionData.currentPath);

            while (subFolders.Count != 0)
            {
                string currentPath = subFolders.Dequeue();
                int    identation  = currentPath.Split('\\').Length - initialIdentation;

                OutputWriter.WriteMessage(currentPath);
                try
                {
                    foreach (var file in Directory.GetFiles(currentPath))
                    {
                        int    indexOfLastSlash = file.LastIndexOf("\\");
                        string fileName         = file.Substring(indexOfLastSlash);
                        OutputWriter.WriteMessageOnNewLIne(new string('-', indexOfLastSlash) + fileName);
                    }

                    foreach (var directoryPath in Directory.GetDirectories(currentPath))
                    {
                        subFolders.Enqueue(directoryPath);
                    }
                }
                catch (UnauthorizedAccessException)
                {
                    OutputWriter.DisplayException(ExceptionMessages.UnauthorizedAccessExceptionMessage);
                }
                OutputWriter.WriteMessageOnNewLIne(string.Format("{0}{1}", new string('-', identation), currentPath));

                if (depth - identation < 0)
                {
                    break;
                }
            }
        }
 private static void DisplayInvalidCommandMessage(string input)
 {
     OutputWriter.WriteMessage($"The command '{input}' is invalid");
 }