-
Notifications
You must be signed in to change notification settings - Fork 0
Console
The console UI uses the implemented operations of the file system to allow the user to interact with it.
The ConsoleUI.java class has a static variable that stores the current directory the user is in. Every time it changes (by using the command cd) it is updated.
In order to process user input and commands, the Strategy pattern was implemented to allow new features to be added easily in the feature.
static {
commands.put("cd", new ChangeDir());
commands.put("cp", new Copy());
commands.put("mv", new Move());
commands.put("ls", new ListDir());
commands.put("touch", new CreateFile());
commands.put("mkdir", new CreateFolder());
commands.put("rm", new Delete());
commands.put("cat", new ShowFileContent());
}Used to navigate inside the file structure
Usage:
cd .. - goes back one level
cd <relative path of folder> - navigated to the folder specified
Creates a new File with a given name and contents in the current directory
Usage: touch <name of file> <file contents>
Creates a new Folder with a given name in the current directory
Usage: mkdir <name of folder
Needs to be used in the same path as the item that's going to be copied
Usage: cp <relative path of item to be copied> <absolute path of destination folder>
Moves one item from one location to another destination
Usage: mv <relative path of item to be copied> <absolute path of destination folder>
Deletes one item from the current directory
Usage: rm <relative path of item to be deleted>
Lists all items in the current directory and shows additional information about each one
Usage: ls
Shows the text contents of a given file.
Usage: cat <relative path of the desired file>