Exemple #1
0
 public void List_Commands()
 {
     listCommands.List_Commands();
 }
        public void ExecuteCommand(string command)
        {
            var commandDetails = command.Split(" ");

            switch (commandDetails[0])
            {
            case "exit":
                shouldExit = true;
                break;

            case "addFile":
                currentFolder.Add(new File(currentFolder, commandDetails[1], (currentFolder.Path + "/" + commandDetails[1])));
                break;

            case "addFolder":
                currentFolder.Add(new Folder(currentFolder, commandDetails[1], (currentFolder.Path + "/" + commandDetails[1])));
                break;

            case "deleteFile":
                currentFolder.Remove(currentFolder.GetFileByName(commandDetails[1]));
                break;

            case "deleteFolder":
                currentFolder.Remove(currentFolder.GetFolderByName(commandDetails[1]));
                break;

            //case "list":
            //    ListContents();
            //    break;
            //case "listAll":
            //    ListAllContents();
            //    break;
            case "commands":
                listCommands.List_Commands();
                break;

            case "openFolder":
                var targetFolder = currentFolder.GetFolderByName(commandDetails[1]);
                if (targetFolder != null)
                {
                    currentFolder = targetFolder;
                }
                else
                {
                    Console.WriteLine("#Error folder does not exist");
                }
                break;

            case "closeFolder":
                var targetFolder2 = currentFolder.Parent;
                if (targetFolder2 != null)
                {
                    currentFolder = targetFolder2;
                }
                else
                {
                    Console.WriteLine("#Error You are at the root");
                }
                break;

            default:
                Console.WriteLine("Command does not exist");
                break;
            }
        }