0
我試圖用gogoshell添加一些控制檯命令 比如我創建命令添加並顯示gogoshell自己的命令管道
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);
}
,當我使用他們喜歡
add 1 | add 2 | add 3 | add 4 | show
我歌廳像
null pointer Exception
或
1
3
4
2
我認爲這是因爲管道(add)並行運行。那麼我怎樣才能在管道連續的地方編寫命令。