I'm trying to use gogo-shell to add some console commands For example I'm create commands add and show
public void add(CommandSession commandSession, int i) {
List<Integer> il = commandSession.get("list");
if (il == null) {
il = new ArrayList<Integer>();
il.add(i);
commandSession.put("list",il)
} else {
il.add(i)
}
}
public void show(CommandSession commandSession) {
List<Integer> il = commandSession.get("list");
il.foreach(System.out::println);
}
and when i use them like
add 1 | add 2 | add 3 | add 4 | show
I'm geting something like
null pointer Exception
or
1
3
4
2
I think this happens because pipes (add) runs in parallel. So how can I write command where piping will be sequential.