public void handle(Command command, String[] args, Application application) throws CommandException { try { if (command == Command.ls) { PersistentTradingClient client = application.getTradingClient(); if (args.length == 0) { String[] outstandingOrders = client.getOutstandingOrders(); System.out.println(); CommandHelper.displayTradeTable(System.out, client, outstandingOrders); System.out.println(); CommandHelper.displayBlockTable(System.out, client, outstandingOrders); System.out.println(); } else if (args.length == 1) { String arg = args[0]; System.out.println(); if (arg.equals(TR_OPTION)) { CommandHelper.displayTradeTable(System.out, client, client.getOutstandingOrders()); } else if (arg.equals(BT_OPTION)) { CommandHelper.displayBlockTable(System.out, client, client.getOutstandingOrders()); } else { PersistentOrder order = client.load(arg); if (order != null) { CommandHelper.displayOrder(System.out, order); } else { System.out.println("Order not found: " + arg); } } System.out.println(); } else if (args.length == 2) { if (args[0].equals(ORDER_OPTION)) { String pmsId = args[1].equals("-") ? null : args[1]; System.out.println(); System.out.println("TRs: " + Arrays.toString(client.getPomsIds(pmsId))); System.out.println(); } else { throw new CommandException(); } } else { throw new CommandException(); } } else { throw new AssertionError("Unknown list command: " + command); } } catch (TimeoutException e) { System.out.println("Order not found: " + e); } }