List of usage examples for org.apache.commons.cli2 DisplaySetting DISPLAY_GROUP_OUTER
DisplaySetting DISPLAY_GROUP_OUTER
To view the source code for org.apache.commons.cli2 DisplaySetting DISPLAY_GROUP_OUTER.
Click Source Link
From source file:br.edu.ifpb.pos.command.CommandExecute.java
@Override public void run() throws ResourceException { System.out.println(""); if (line.hasOption("--help")) { HelpFormatter helpFormatter = new HelpFormatter(); helpFormatter.setGroup(options); helpFormatter.setDivider(" "); helpFormatter.getFullUsageSettings().remove(DisplaySetting.DISPLAY_GROUP_OUTER); helpFormatter.print();//from w w w .j av a2s . co m } if (line.hasOption("--insert")) { Representation representation = new StringRepresentation((CharSequence) line.getValue("--insert"), MediaType.APPLICATION_JSON); ClientResource clientResource; if (line.getValue("--type").equals(TYPE_PERSON)) { clientResource = new ClientResource(URL + "/person"); } else { clientResource = new ClientResource(URL + "/user"); } try { clientResource.post(representation).write(System.out); System.out.println(""); } catch (IOException ex) { Logger.getLogger(CommandExecute.class.getName()).log(Level.SEVERE, null, ex); } } if (line.hasOption("--update")) { String entity = (String) line.getValue("--update"); Representation representation = new StringRepresentation(entity, MediaType.APPLICATION_JSON); ClientResource clientResource; Gson gson = new Gson(); if (line.getValue("--type").equals(TYPE_PERSON)) { Key key = gson.fromJson(entity, Key.class); clientResource = new ClientResource(URL + "/person/" + key.getKey()); } else { Key key = gson.fromJson(entity, Key.class); clientResource = new ClientResource(URL + "/user/" + key.getKey()); } try { clientResource.put(representation).write(System.out); System.out.println(""); } catch (IOException ex) { Logger.getLogger(CommandExecute.class.getName()).log(Level.SEVERE, null, ex); } } if (line.hasOption("--delete")) { ClientResource clientResource; String key = getKey(line.getValue("--delete").toString()); if (line.getValue("--type").equals(TYPE_PERSON)) { clientResource = new ClientResource(URL + "/person/" + key); } else { clientResource = new ClientResource(URL + "/user/" + key); } try { clientResource.delete().write(System.out); System.out.println(""); } catch (IOException ex) { Logger.getLogger(CommandExecute.class.getName()).log(Level.SEVERE, null, ex); } } if (line.hasOption("--select")) { ClientResource clientResource; String key = getKey(line.getValue("--select").toString()); if (line.getValue("--type").equals(TYPE_PERSON)) { clientResource = new ClientResource(URL + "/person/" + key); } else { clientResource = new ClientResource(URL + "/user/" + key); } Representation representation = clientResource.get(); try { System.out.println(representation.getText()); } catch (IOException ex) { Logger.getLogger(CommandExecute.class.getName()).log(Level.SEVERE, null, ex); } } }