File tree Expand file tree Collapse file tree 7 files changed +18
-0
lines changed
main/java/seedu/address/logic
test/java/seedu/address/logic/parser Expand file tree Collapse file tree 7 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -172,6 +172,8 @@ Example: `archive pa/mybook.json`
172
172
173
173
The file name must ends with ".json" and must not contain any slash "/".
174
174
175
+ There should be only one file name provided.
176
+
175
177
#### Warning
176
178
177
179
All the entries in the current address book will be cleared.
@@ -190,6 +192,8 @@ Example: `load pa/mybook.json`
190
192
191
193
The file name must ends with ".json", must not contain any slash "/" and must point to an existing address book .json file.
192
194
195
+ There should be only one file name provided.
196
+
193
197
#### Warning
194
198
Avoid loading non-address book .json files as it may result in unexpected behaviours
195
199
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ public class ArchiveCommand extends Command {
16
16
public static final String MESSAGE_USAGE = COMMAND_WORD + " " + PREFIX_PATH + "FileName\n "
17
17
+ "The file name should be a path of an json file "
18
18
+ "and not contain any slash `/` \n "
19
+ + "There should be only one path provided.\n "
19
20
+ "Example: " + COMMAND_WORD + " " + PREFIX_PATH + "mybook.json" ;
20
21
public static final String MESSAGE_SUCCESS = "Archive Path changed to: %1$s" ;
21
22
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ public class LoadCommand extends Command {
16
16
public static final String MESSAGE_USAGE = COMMAND_WORD + " " + PREFIX_PATH + "FileName\n "
17
17
+ "The file name should be a path of an json file containing an address book "
18
18
+ "and not contain any slash `/` \n "
19
+ + "There should be only one path provided.\n "
19
20
+ "Example: " + COMMAND_WORD + " " + PREFIX_PATH + "mybook.json" ;
20
21
public static final String MESSAGE_SUCCESS = "Loading file from: %1$s" ;
21
22
Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ public ArchiveCommand parse(String args) throws ParseException {
26
26
if (!arePrefixesPresent (argMultimap , PREFIX_PATH )) {
27
27
throw new ParseException (String .format (MESSAGE_INVALID_COMMAND_FORMAT , ArchiveCommand .MESSAGE_USAGE ));
28
28
}
29
+ argMultimap .verifyNoDuplicatePrefixesFor (PREFIX_PATH );
29
30
Path path = ParserUtil .parsePathWithoutCheck (argMultimap .getValue (PREFIX_PATH ).get ());
30
31
return new ArchiveCommand (path );
31
32
}
Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ public LoadCommand parse(String args) throws ParseException {
26
26
if (!arePrefixesPresent (argMultimap , PREFIX_PATH )) {
27
27
throw new ParseException (String .format (MESSAGE_INVALID_COMMAND_FORMAT , LoadCommand .MESSAGE_USAGE ));
28
28
}
29
+ argMultimap .verifyNoDuplicatePrefixesFor (PREFIX_PATH );
29
30
Path path = ParserUtil .parsePathWithCheck (argMultimap .getValue (PREFIX_PATH ).get ());
30
31
return new LoadCommand (path );
31
32
}
Original file line number Diff line number Diff line change 1
1
package seedu .address .logic .parser ;
2
2
3
3
import static seedu .address .logic .Messages .MESSAGE_INVALID_COMMAND_FORMAT ;
4
+ import static seedu .address .logic .parser .CliSyntax .PREFIX_PATH ;
4
5
import static seedu .address .logic .parser .CommandParserTestUtil .assertParseFailure ;
5
6
import static seedu .address .logic .parser .CommandParserTestUtil .assertParseSuccess ;
6
7
7
8
import java .nio .file .Paths ;
8
9
9
10
import org .junit .jupiter .api .Test ;
10
11
12
+ import seedu .address .logic .Messages ;
11
13
import seedu .address .logic .commands .ArchiveCommand ;
12
14
13
15
public class ArchiveCommandParserTest {
14
16
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" ;
15
18
private static final String VALID_INPUT = "archive pa/TestValidInput.json" ;
16
19
private static final ArchiveCommandParser PARSER = new ArchiveCommandParser ();
17
20
18
21
@ Test
19
22
void invalid_input_throwException () {
20
23
assertParseFailure (PARSER , INPUT_MISSING_PREFIX ,
21
24
String .format (MESSAGE_INVALID_COMMAND_FORMAT , ArchiveCommand .MESSAGE_USAGE ));
25
+ assertParseFailure (PARSER , INPUT_MULTIPLE_PATH ,
26
+ String .format (Messages .getErrorMessageForDuplicatePrefixes (PREFIX_PATH )));
22
27
}
23
28
24
29
@ Test
Original file line number Diff line number Diff line change 1
1
package seedu .address .logic .parser ;
2
2
3
3
import static seedu .address .logic .Messages .MESSAGE_INVALID_COMMAND_FORMAT ;
4
+ import static seedu .address .logic .parser .CliSyntax .PREFIX_PATH ;
4
5
import static seedu .address .logic .parser .CommandParserTestUtil .assertParseFailure ;
5
6
import static seedu .address .logic .parser .CommandParserTestUtil .assertParseSuccess ;
6
7
10
11
11
12
import org .junit .jupiter .api .Test ;
12
13
14
+ import seedu .address .logic .Messages ;
13
15
import seedu .address .logic .commands .LoadCommand ;
14
16
15
17
16
18
public class LoadCommandParserTest {
17
19
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" ;
18
21
private static final String VALID_INPUT = "load pa/TestValidInput.json" ;
19
22
private static final LoadCommandParser PARSER = new LoadCommandParser ();
20
23
21
24
@ Test
22
25
void invalid_input_throwException () {
23
26
assertParseFailure (PARSER , INPUT_MISSING_PREFIX ,
24
27
String .format (MESSAGE_INVALID_COMMAND_FORMAT , LoadCommand .MESSAGE_USAGE ));
28
+ assertParseFailure (PARSER , INPUT_MULTIPLE_PATH ,
29
+ String .format (Messages .getErrorMessageForDuplicatePrefixes (PREFIX_PATH )));
25
30
}
26
31
27
32
@ Test
You can’t perform that action at this time.
0 commit comments