Skip to content

Commit bf9e7d1

Browse files
committed
Merge branch 'master' of https://github.com/AY2425S1-CS2103T-W10-4/tp into Feature-Complete-AutoCompletePath
* 'master' of https://github.com/AY2425S1-CS2103T-W10-4/tp: Add the requirement of only one file name into the User guide Update the archive command and load command
2 parents 7962ce5 + 53fd907 commit bf9e7d1

File tree

7 files changed

+18
-0
lines changed

7 files changed

+18
-0
lines changed

docs/UserGuide.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,8 @@ Example: `archive pa/mybook.json`
172172

173173
The file name must ends with ".json" and must not contain any slash "/".
174174

175+
There should be only one file name provided.
176+
175177
#### Warning
176178

177179
All the entries in the current address book will be cleared.
@@ -190,6 +192,8 @@ Example: `load pa/mybook.json`
190192

191193
The file name must ends with ".json", must not contain any slash "/" and must point to an existing address book .json file.
192194

195+
There should be only one file name provided.
196+
193197
#### Warning
194198
Avoid loading non-address book .json files as it may result in unexpected behaviours
195199

src/main/java/seedu/address/logic/commands/ArchiveCommand.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public class ArchiveCommand extends Command {
1616
public static final String MESSAGE_USAGE = COMMAND_WORD + " " + PREFIX_PATH + "FileName\n"
1717
+ "The file name should be a path of an json file "
1818
+ "and not contain any slash `/` \n"
19+
+ "There should be only one path provided.\n"
1920
+ "Example: " + COMMAND_WORD + " " + PREFIX_PATH + "mybook.json";
2021
public static final String MESSAGE_SUCCESS = "Archive Path changed to: %1$s";
2122

src/main/java/seedu/address/logic/commands/LoadCommand.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public class LoadCommand extends Command {
1616
public static final String MESSAGE_USAGE = COMMAND_WORD + " " + PREFIX_PATH + "FileName\n"
1717
+ "The file name should be a path of an json file containing an address book "
1818
+ "and not contain any slash `/` \n"
19+
+ "There should be only one path provided.\n"
1920
+ "Example: " + COMMAND_WORD + " " + PREFIX_PATH + "mybook.json";
2021
public static final String MESSAGE_SUCCESS = "Loading file from: %1$s";
2122

src/main/java/seedu/address/logic/parser/ArchiveCommandParser.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public ArchiveCommand parse(String args) throws ParseException {
2626
if (!arePrefixesPresent(argMultimap, PREFIX_PATH)) {
2727
throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, ArchiveCommand.MESSAGE_USAGE));
2828
}
29+
argMultimap.verifyNoDuplicatePrefixesFor(PREFIX_PATH);
2930
Path path = ParserUtil.parsePathWithoutCheck(argMultimap.getValue(PREFIX_PATH).get());
3031
return new ArchiveCommand(path);
3132
}

src/main/java/seedu/address/logic/parser/LoadCommandParser.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public LoadCommand parse(String args) throws ParseException {
2626
if (!arePrefixesPresent(argMultimap, PREFIX_PATH)) {
2727
throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, LoadCommand.MESSAGE_USAGE));
2828
}
29+
argMultimap.verifyNoDuplicatePrefixesFor(PREFIX_PATH);
2930
Path path = ParserUtil.parsePathWithCheck(argMultimap.getValue(PREFIX_PATH).get());
3031
return new LoadCommand(path);
3132
}

src/test/java/seedu/address/logic/parser/ArchiveCommandParserTest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,29 @@
11
package seedu.address.logic.parser;
22

33
import static seedu.address.logic.Messages.MESSAGE_INVALID_COMMAND_FORMAT;
4+
import static seedu.address.logic.parser.CliSyntax.PREFIX_PATH;
45
import static seedu.address.logic.parser.CommandParserTestUtil.assertParseFailure;
56
import static seedu.address.logic.parser.CommandParserTestUtil.assertParseSuccess;
67

78
import java.nio.file.Paths;
89

910
import org.junit.jupiter.api.Test;
1011

12+
import seedu.address.logic.Messages;
1113
import seedu.address.logic.commands.ArchiveCommand;
1214

1315
public class ArchiveCommandParserTest {
1416
private static final String INPUT_MISSING_PREFIX = "archive mybook.json";
17+
private static final String INPUT_MULTIPLE_PATH = "archive pa/mybook.json pa/mybook2.json";
1518
private static final String VALID_INPUT = "archive pa/TestValidInput.json";
1619
private static final ArchiveCommandParser PARSER = new ArchiveCommandParser();
1720

1821
@Test
1922
void invalid_input_throwException() {
2023
assertParseFailure(PARSER, INPUT_MISSING_PREFIX,
2124
String.format(MESSAGE_INVALID_COMMAND_FORMAT, ArchiveCommand.MESSAGE_USAGE));
25+
assertParseFailure(PARSER, INPUT_MULTIPLE_PATH,
26+
String.format(Messages.getErrorMessageForDuplicatePrefixes(PREFIX_PATH)));
2227
}
2328

2429
@Test

src/test/java/seedu/address/logic/parser/LoadCommandParserTest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package seedu.address.logic.parser;
22

33
import static seedu.address.logic.Messages.MESSAGE_INVALID_COMMAND_FORMAT;
4+
import static seedu.address.logic.parser.CliSyntax.PREFIX_PATH;
45
import static seedu.address.logic.parser.CommandParserTestUtil.assertParseFailure;
56
import static seedu.address.logic.parser.CommandParserTestUtil.assertParseSuccess;
67

@@ -10,18 +11,22 @@
1011

1112
import org.junit.jupiter.api.Test;
1213

14+
import seedu.address.logic.Messages;
1315
import seedu.address.logic.commands.LoadCommand;
1416

1517

1618
public class LoadCommandParserTest {
1719
private static final String INPUT_MISSING_PREFIX = "load mybook.json";
20+
private static final String INPUT_MULTIPLE_PATH = "load pa/mybook.json, pa/mybook2.json";
1821
private static final String VALID_INPUT = "load pa/TestValidInput.json";
1922
private static final LoadCommandParser PARSER = new LoadCommandParser();
2023

2124
@Test
2225
void invalid_input_throwException() {
2326
assertParseFailure(PARSER, INPUT_MISSING_PREFIX,
2427
String.format(MESSAGE_INVALID_COMMAND_FORMAT, LoadCommand.MESSAGE_USAGE));
28+
assertParseFailure(PARSER, INPUT_MULTIPLE_PATH,
29+
String.format(Messages.getErrorMessageForDuplicatePrefixes(PREFIX_PATH)));
2530
}
2631

2732
@Test

0 commit comments

Comments
 (0)