Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed bug that did not allow Help command to properly show descriptio… #307

Merged
merged 2 commits into from
Nov 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/main/java/executor/command/CommandHelp.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public void execute(StorageManager storageManager) {
exists in the list of available commands.*/
if (!specificCommand.isEmpty()) {
for (String b : CommandType.getNames()) {
if (b.equals(specificCommand)) {
if (b.equals(specificCommand) & this.checkValidCommand(b)) {
StringBuilder outputsSpecificCommandDesc = getDescriptionOfSpecificCommand(b);
this.infoCapsule.setCodeCli();
this.infoCapsule.setOutputStr(outputsSpecificCommandDesc.toString());
Expand All @@ -42,7 +42,7 @@ public void execute(StorageManager storageManager) {

ArrayList<String> listToStoreAllCommands = new ArrayList<String>();
for (String s : CommandType.getNames()) {
if (!s.equals("ERROR") && !s.equals("TASK") && !s.equals("BLANK")) {
if (this.checkValidCommand(s)) {
getDescriptionOfAllCommands(s, listToStoreAllCommands);
Collections.sort(listToStoreAllCommands, String.CASE_INSENSITIVE_ORDER);
}
Expand All @@ -52,15 +52,12 @@ public void execute(StorageManager storageManager) {
}
this.infoCapsule.setCodeCli();
this.infoCapsule.setOutputStr(outputStr.toString());
for (String b : listToStoreAllCommands) {
System.out.println(b);
}
}

private StringBuilder getDescriptionOfSpecificCommand(String b) {
StringBuilder out = new StringBuilder();
CommandType specificCommandType = CommandType.valueOf(b);
Command specific = Executor.createCommand(specificCommandType, "null");
Command specific = Executor.createCommand(specificCommandType, specificCommandType.toString());
String specificDesc = specific.getDescription();
String specificOut = b.toUpperCase() + " - " + specificDesc + "\n";
out.append(specificOut).append("\n");
Expand All @@ -69,10 +66,13 @@ private StringBuilder getDescriptionOfSpecificCommand(String b) {

private void getDescriptionOfAllCommands(String s, ArrayList<String> newOut) {
CommandType commandType = CommandType.valueOf(s);
Command c = Executor.createCommand(commandType, "null");
Command c = Executor.createCommand(commandType, commandType.toString());
String commandDesc = c.getDescription();
String temp = s.toUpperCase() + " - " + commandDesc + "\n";
newOut.add(temp);
return;
}

private boolean checkValidCommand(String s) {
return !s.equals("ERROR") && !s.equals("TASK") && !s.equals("BLANK");
}
}
4 changes: 2 additions & 2 deletions src/main/java/executor/command/CommandNewTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ public CommandNewTask(String userInput) {
this.userInput = userInput;
this.commandType = CommandType.TASK;
this.taskType = extractTaskType();
this.description = "Adds user entry to the list \n"
+ "FORMAT : ";
this.description = "Adds a new " + this.taskType.toString().toLowerCase() + " to your task list.\n"
+ "FORMAT: " + this.taskType.toString() + " <name> /<tag> <desc>";
}

@Override
Expand Down