On top of having a HashMap to look up commands, should we have an array of valid commands, and we see what commands could possibly match with the string that was input? E.g.
int n = cmdStr.length();
for (String validCmd : validCmdArr) {
if (n <= validCmd.length()) {
if (cmdStr.equals(validCmd.substring(0, n))) {
if (validCmd.length() == n) {
//exact match for valid command, execute the command here
break;
} else {
//add validCmd to array of possible valid command strings to display to user here
}
}
}
}
//if by the end of the loop there is only one valid command in the array, prompt the user if this is what he wants to do