List of usage examples for org.apache.commons.cli2.util HelpFormatter getFullUsageSettings
public Set getFullUsageSettings()
From source file:egat.cli.Main.java
protected static void printHelp(Group options) { HelpFormatter hf = new HelpFormatter(); hf.setShellCommand("egat"); hf.setGroup(options);//from www.j a va 2s. com hf.getFullUsageSettings().add(DisplaySetting.DISPLAY_GROUP_NAME); hf.getFullUsageSettings().remove(DisplaySetting.DISPLAY_GROUP_ARGUMENT); hf.getFullUsageSettings().remove(DisplaySetting.DISPLAY_GROUP_EXPANDED); hf.getFullUsageSettings().remove(DisplaySetting.DISPLAY_OPTIONAL_CHILD_GROUP); hf.setFooter("egat is developed by Patrick R. Jordan (prjordan@umich.edu)."); hf.print(); }
From source file:com.ibm.jaql.util.shell.JaqlShellArguments.java
@SuppressWarnings("unchecked") private static void printHelpAndExit(Exception e, String message, Group options) { if (message != null) System.err.println(message); if (e != null) e.printStackTrace();//from w w w . j av a 2 s . co m HelpFormatter hf = new HelpFormatter(); hf.setShellCommand("jaqlshell"); hf.setGroup(options); hf.getFullUsageSettings().remove(DisplaySetting.DISPLAY_GROUP_EXPANDED); hf.getLineUsageSettings().add(DisplaySetting.DISPLAY_ARGUMENT_BRACKETED); hf.print(); hf.printHelp(); System.exit(1); }
From source file:it.jnrpe.server.JNRPEServer.java
/** * Prints the JNRPE Server usage and, eventually, the error about the last * invocation./*from w w w . java2s.com*/ * * @param e * The last error. Can be null. */ @SuppressWarnings("unchecked") private static void printUsage(final Exception e) { printVersion(); if (e != null) { System.out.println(e.getMessage() + "\n"); } HelpFormatter hf = new HelpFormatter(); StringBuilder sbDivider = new StringBuilder("="); while (sbDivider.length() < hf.getPageWidth()) { sbDivider.append("="); } // DISPLAY SETTING hf.getDisplaySettings().clear(); hf.getDisplaySettings().add(DisplaySetting.DISPLAY_GROUP_EXPANDED); hf.getDisplaySettings().add(DisplaySetting.DISPLAY_PARENT_CHILDREN); // USAGE SETTING hf.getFullUsageSettings().clear(); hf.getFullUsageSettings().add(DisplaySetting.DISPLAY_PARENT_ARGUMENT); hf.getFullUsageSettings().add(DisplaySetting.DISPLAY_ARGUMENT_BRACKETED); hf.getFullUsageSettings().add(DisplaySetting.DISPLAY_PARENT_CHILDREN); hf.getFullUsageSettings().add(DisplaySetting.DISPLAY_GROUP_EXPANDED); hf.setDivider(sbDivider.toString()); hf.setGroup(configureCommandLine()); hf.print(); System.exit(0); }
From source file:it.jnrpe.client.JNRPEClient.java
/** * Prints usage instrunctions and, eventually, an error message about the * latest execution./*w w w . ja v a 2 s. com*/ * * @param e * The exception error */ @SuppressWarnings("unchecked") private static void printUsage(final Exception e) { printVersion(); StringBuilder sbDivider = new StringBuilder("="); if (e != null) { System.out.println(e.getMessage() + "\n"); } HelpFormatter hf = new HelpFormatter(); while (sbDivider.length() < hf.getPageWidth()) { sbDivider.append('='); } // DISPLAY SETTING Set displaySettings = hf.getDisplaySettings(); displaySettings.clear(); displaySettings.add(DisplaySetting.DISPLAY_GROUP_EXPANDED); displaySettings.add(DisplaySetting.DISPLAY_PARENT_CHILDREN); // USAGE SETTING Set usageSettings = hf.getFullUsageSettings(); usageSettings.clear(); usageSettings.add(DisplaySetting.DISPLAY_PARENT_ARGUMENT); usageSettings.add(DisplaySetting.DISPLAY_ARGUMENT_BRACKETED); usageSettings.add(DisplaySetting.DISPLAY_PARENT_CHILDREN); usageSettings.add(DisplaySetting.DISPLAY_GROUP_EXPANDED); hf.setDivider(sbDivider.toString()); hf.setGroup(configureCommandLine()); hf.print(); }
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 ww w. ja v a 2s . c o 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); } } }
From source file:egat.cli.AbstractGameCommandHandler.java
protected void printHelp() { HelpFormatter hf = new HelpFormatter(); hf.setShellCommand("egat " + getCommandName()); hf.setGroup(getCommand().getChildren()); hf.getFullUsageSettings().add(DisplaySetting.DISPLAY_GROUP_NAME); hf.getFullUsageSettings().remove(DisplaySetting.DISPLAY_GROUP_ARGUMENT); hf.getFullUsageSettings().remove(DisplaySetting.DISPLAY_GROUP_EXPANDED); hf.getFullUsageSettings().remove(DisplaySetting.DISPLAY_OPTIONAL_CHILD_GROUP); hf.setFooter("egat is developed by Patrick R. Jordan (prjordan@umich.edu)."); hf.print();// w w w . ja v a 2 s . co m }