forked from nus-cs2103-AY1718S2/addressbook-level4
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request nus-cs2103-AY1718S2#43 from jasmoon/master
Enhance help/man command
- Loading branch information
Showing
6 changed files
with
132 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
src/main/java/seedu/address/logic/parser/HelpCommandParser.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package seedu.address.logic.parser; | ||
|
||
import java.util.ArrayList; | ||
|
||
import seedu.address.logic.commands.HelpCommand; | ||
import seedu.address.logic.parser.exceptions.ParseException; | ||
|
||
|
||
|
||
//@@author jasmoon | ||
|
||
/** | ||
* Parses input arguments and create a new HelpCommand object. | ||
*/ | ||
public class HelpCommandParser implements Parser<HelpCommand> { | ||
|
||
public final ArrayList<String> availableCommands; | ||
|
||
/** | ||
* HelpCommandParser constructor - creates an ArrayList which contains all commands open to the help function. | ||
*/ | ||
public HelpCommandParser() { | ||
availableCommands = new ArrayList<String>(); | ||
availableCommands.add("add"); | ||
availableCommands.add("delete"); | ||
availableCommands.add("edit"); | ||
availableCommands.add("find"); | ||
availableCommands.add("select"); | ||
} | ||
|
||
/** | ||
* Parses the given {@code String} of arguments in the context of the HelpCommand | ||
* and returns an HelpCommand object for execution. | ||
* @throws ParseException if the user input does not conform the expected format | ||
*/ | ||
|
||
public HelpCommand parse(String args) throws ParseException { | ||
|
||
String commandRequest = args.trim(); | ||
if (commandRequest.length() == 0) { | ||
return new HelpCommand(); | ||
} else { | ||
if (availableCommands.contains(commandRequest)) { | ||
return new HelpCommand(args); | ||
} else { | ||
throw new ParseException(formInvalidMessage(commandRequest)); | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* | ||
* @param commandRequest | ||
* @return String message for invalid command request. | ||
*/ | ||
private String formInvalidMessage(String commandRequest) { | ||
return "Help for '" + commandRequest + "' is unknown or not available."; | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters