Interactive command processor developed for the Salesforce technical challenge.
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
- Clone the Command Processor repository.
git clone https://github.com/brianfroschauer/commandprocessor.git
- Change directory to commandprocessor package.
cd commandprocessor
- Compile the application.
mvn compile
- Execute the application.
mvn exec:java -Dexec.mainClass=commandprocessor.Main
- Try executing some command like
ls
in the command line.
This command changes the current path to a sub-directory (by name).
cd <directoryName>
This command creates a "file" in the current directory.
touch <fileName>
This command print the full path of the current directory.
pwd
This command lists the contents (directories and files) of current directory. If recursive parameter is provided, prints everything in the current directory and all subdirectories.
ls
List recursive:
ls -r
This command creates a directory entry in the cache.
mkdir <directoryName>
This command interrupt the program.
quit
Run all the unit test classes using maven.
mvn test
The main components are described below.
Used as interface for all specific commands. It receives the file as argument in which the command will be executed, and returns a command output object that contains the result file of the execution and the output logs as a list of strings.
@FunctionalInterface
public interface Command {
CommandOutput execute(final @NotNull File file);
}
The command processor knows how to execute all provided commands in the specific provided file.
public interface CommandProcessor {
List<CommandOutput> execute(final @NotNull File file, final @NotNull List<Command> commands);
CommandOutput execute(final @NotNull File file, @NotNull final Command command);
}
The command factory knows how to create a command given the command arguments as an array of strings. It also has a method that returns the command used as the factory strategy name.
public interface CommandFactory {
CommandName getCommandName();
Command create(final String... arguments);
}
- Maven - Dependency Management
- Brian Froschauer