Skip to content

Commit

Permalink
Merge pull request #85 from winsonheng/master
Browse files Browse the repository at this point in the history
Allow optional keyword shown for export and all for import
  • Loading branch information
winsonheng authored Mar 30, 2023
2 parents f9430ef + db833ee commit bdcbba8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,19 @@
*/
public class ExportCommandParser implements Parser<ExportCommand> {
private static final String ALL_KEYWORD = "all";
private static final String SHOWN_KEYWORD = "shown";

/**
* Creates a ExportCommand where isAllEnabled depends on the parsed user input.
* If keyword is "shown" or no keyword is present, export only the filtered list.
*
* @param args The input from user.
* @return ExportCommand with isAllEnabled set to true if the keyword "all" is in the user input.
* @throws ParseException If the command is in invalid format.
*/
public ExportCommand parse(String args) throws ParseException {
String trimmedArgs = args.trim().toLowerCase();
if (trimmedArgs.isEmpty()) {
if (trimmedArgs.isEmpty() || trimmedArgs.equals(SHOWN_KEYWORD)) {
return new ExportCommand(false);
} else if (trimmedArgs.equals(ALL_KEYWORD)) {
return new ExportCommand(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,19 @@
*/
public class ImportCommandParser implements Parser<ImportCommand> {
private static final String RESET_KEYWORD = "reset";
private static final String COMBINE_KEYWORD = "combine";

/**
* Creates a ImportCommand where isResetEnabled depends on the parsed user input.
* If keyword is "combine" or no keyword is present, combine the imported dataset with the existing one.
*
* @param args The input from user.
* @return ImportCommand with isResetEnabled set to true if the keyword "reset" is in the user input.
* @throws ParseException If the command is in invalid format.
*/
public ImportCommand parse(String args) throws ParseException {
String trimmedArgs = args.trim().toLowerCase();
if (trimmedArgs.isEmpty()) {
if (trimmedArgs.isEmpty() || trimmedArgs.equals(COMBINE_KEYWORD)) {
return new ImportCommand(false);
} else if (trimmedArgs.equals(RESET_KEYWORD)) {
return new ImportCommand(true);
Expand Down

0 comments on commit bdcbba8

Please sign in to comment.