|
@@ -49,63 +49,64 @@ public class SimpleShell {
|
49
|
49
|
MessageController mesCont = new MessageController();
|
50
|
50
|
IdController idCont = new IdController();
|
51
|
51
|
|
52
|
|
-
|
53
|
52
|
if (commandLine.equalsIgnoreCase("ids")) {
|
54
|
|
- System.out.println("To retrieve all registered github ids, press enter\nTo register a new id " +
|
55
|
|
- "or change the name associated, type the name followed by the github id");
|
|
53
|
+ String results = "";
|
|
54
|
+ System.out.println("To retrieve all registered github ids, press enter\n" +
|
|
55
|
+ "To register a new id or change the name associated, type your name");
|
56
|
56
|
specificCommand = console.readLine();
|
57
|
|
- if(specificCommand.equals("\n")) {
|
58
|
|
- String results = idCont.get_ids(commandList);
|
59
|
|
- SimpleShell.prettyPrint(results);
|
60
|
|
- continue;
|
|
57
|
+ if(specificCommand.equals("")) {
|
|
58
|
+ results = idCont.get_ids(commandList);
|
61
|
59
|
} else {
|
62
|
|
- String [] c = specificCommand.split(" ");
|
63
|
|
- commandList.addAll(Arrays.asList(c));
|
64
|
|
- String save = idCont.saveId(commandList);
|
65
|
|
- SimpleShell.prettyPrint(save);
|
|
60
|
+ commandList.add(specificCommand);
|
|
61
|
+ System.out.println("Please enter your github id");
|
|
62
|
+ specificCommand = console.readLine();
|
|
63
|
+ commandList.add(specificCommand);
|
|
64
|
+ results = idCont.saveId(commandList);
|
66
|
65
|
}
|
|
66
|
+ SimpleShell.prettyPrint(results);
|
|
67
|
+ continue;
|
67
|
68
|
}
|
68
|
69
|
|
69
|
70
|
if (commandLine.equals("messages")) {
|
|
71
|
+ String results = "";
|
70
|
72
|
System.out.println("To retrieve the last 20 messages posted on the timeline, press enter\n" +
|
71
|
73
|
"To retrieve the last twenty messages sent to you enter your github id");
|
72
|
74
|
specificCommand = console.readLine();
|
73
|
|
- if(specificCommand.equals("\n")) {
|
74
|
|
- String results = mesCont.get_messages(commandList);
|
75
|
|
- SimpleShell.prettyPrint(results);
|
76
|
|
- continue;
|
|
75
|
+ if(specificCommand.equals("\n") || specificCommand.equals("")) {
|
|
76
|
+ results = mesCont.get_messages(commandList);
|
77
|
77
|
} else {
|
78
|
78
|
commandList.add(specificCommand);
|
79
|
|
- String results = mesCont.get_my_messages(commandList);
|
80
|
|
- SimpleShell.prettyPrint(results);
|
|
79
|
+ results = mesCont.get_my_messages(commandList);
|
81
|
80
|
}
|
|
81
|
+ SimpleShell.prettyPrint(results);
|
|
82
|
+ continue;
|
82
|
83
|
}
|
83
|
84
|
|
84
|
85
|
|
85
|
86
|
if(commandLine.equalsIgnoreCase("send")){
|
86
|
|
- System.out.println("To send a message on the timeline type in 'your message' and your github id.\n" +
|
87
|
|
- "To send a message to a friend, type 'your message', within single quotes, followed by your github id and then the");
|
|
87
|
+ String results = "";
|
|
88
|
+ System.out.println("Please enter your message");
|
88
|
89
|
specificCommand = console.readLine();
|
89
|
|
- Pattern pattern = Pattern.compile("'.+'");
|
90
|
|
- Matcher matcher = pattern.matcher(specificCommand);
|
91
|
|
- if(matcher.find()){
|
92
|
|
- String one = matcher.group();
|
93
|
|
- String two = specificCommand.substring(matcher.end());
|
94
|
|
- String[] twoSplit = two.split(" ");
|
95
|
|
- commandList.add(one);
|
96
|
|
- if(twoSplit.length == 1){
|
97
|
|
- commandList.add(twoSplit[0]);
|
98
|
|
- String results = mesCont.post_world(commandList);
|
99
|
|
- SimpleShell.prettyPrint(results);
|
100
|
|
- }
|
101
|
|
- if(twoSplit.length == 2){
|
102
|
|
- commandList.add(twoSplit[0]);
|
103
|
|
- commandList.add(twoSplit[1]);
|
104
|
|
- String results = mesCont.post_friend(commandList);
|
105
|
|
- SimpleShell.prettyPrint(results);
|
106
|
|
- }
|
|
90
|
+ if(!specificCommand.equals("")) {
|
|
91
|
+ commandList.add(specificCommand);
|
|
92
|
+ }
|
|
93
|
+ System.out.println(("Enter your github id"));
|
|
94
|
+ if(!specificCommand.equals("")) {
|
|
95
|
+ commandList.add(specificCommand);
|
|
96
|
+ results = mesCont.post_world(commandList);
|
|
97
|
+ }
|
|
98
|
+ System.out.println(("If you wish to send your message to another github user, enter their github id." +
|
|
99
|
+ "If you wish to send a general message to the timeline, press enter"));
|
|
100
|
+ if (specificCommand.equals("")) {
|
|
101
|
+ results = mesCont.post_world(commandList);
|
|
102
|
+ }
|
|
103
|
+ if(!specificCommand.equals("")) {
|
|
104
|
+ commandList.add(specificCommand);
|
|
105
|
+ results = mesCont.post_friend(commandList);
|
|
106
|
+ }
|
|
107
|
+ SimpleShell.prettyPrint(results);
|
|
108
|
+ continue;
|
107
|
109
|
}
|
108
|
|
- }
|
109
|
110
|
|
110
|
111
|
|
111
|
112
|
//print history, moved it here so full commands will be in history
|