|
@@ -1,3 +1,5 @@
|
|
1
|
+import com.fasterxml.jackson.databind.ObjectMapper;
|
|
2
|
+
|
1
|
3
|
import java.io.BufferedReader;
|
2
|
4
|
import java.io.IOException;
|
3
|
5
|
import java.io.InputStream;
|
|
@@ -10,6 +12,15 @@ public class SimpleShell {
|
10
|
12
|
|
11
|
13
|
public static void prettyPrint(String output) {
|
12
|
14
|
// yep, make an effort to format things nicely, eh?
|
|
15
|
+ ObjectMapper mapper = new ObjectMapper();
|
|
16
|
+ try {
|
|
17
|
+ Object json = mapper.readValue(output, Object.class);
|
|
18
|
+ String prettyPrint = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(json);
|
|
19
|
+ System.out.println(prettyPrint);
|
|
20
|
+ } catch (IOException e) {
|
|
21
|
+ e.printStackTrace();
|
|
22
|
+ }
|
|
23
|
+
|
13
|
24
|
System.out.println(output);
|
14
|
25
|
}
|
15
|
26
|
public static void main(String[] args) throws java.io.IOException {
|
|
@@ -18,7 +29,7 @@ public class SimpleShell {
|
18
|
29
|
String commandLine;
|
19
|
30
|
BufferedReader console = new BufferedReader
|
20
|
31
|
(new InputStreamReader(System.in));
|
21
|
|
-
|
|
32
|
+ ObjectMapper mapper = new ObjectMapper();
|
22
|
33
|
ProcessBuilder pb = new ProcessBuilder();
|
23
|
34
|
List<String> history = new ArrayList<String>();
|
24
|
35
|
int index = 0;
|
|
@@ -59,12 +70,21 @@ public class SimpleShell {
|
59
|
70
|
// Specific Commands.
|
60
|
71
|
|
61
|
72
|
// ids
|
62
|
|
- if (list.contains("ids")) {
|
|
73
|
+ if (list.contains("ids") && list.size() ==1) {
|
63
|
74
|
String results = webber.get_ids();
|
64
|
75
|
SimpleShell.prettyPrint(results);
|
65
|
76
|
continue;
|
66
|
77
|
}
|
67
|
78
|
|
|
79
|
+ if (list.contains("ids") && list.size() ==3){
|
|
80
|
+ String name = list.get(1); //name
|
|
81
|
+ String github= list.get(2);
|
|
82
|
+ User user = new User(name, github);
|
|
83
|
+ String newUserInfo = mapper.writeValueAsString(user);
|
|
84
|
+ webber.MakeURLCall("/ids", "POST",newUserInfo);
|
|
85
|
+ continue;
|
|
86
|
+ }
|
|
87
|
+
|
68
|
88
|
// messages
|
69
|
89
|
if (list.contains("messages")) {
|
70
|
90
|
String results = webber.get_messages();
|