use of org.apache.commons.cli.HelpFormatter in project henplus by neurolabs.
the class HenPlus method usageAndExit.
/**
* @param availableOptions
*/
private void usageAndExit(final Options availableOptions, final int returnCode) {
final HelpFormatter formatter = new HelpFormatter();
formatter.printHelp("henplus", availableOptions);
System.exit(returnCode);
}
use of org.apache.commons.cli.HelpFormatter in project brisk by riptano.
the class BriskTool method printUsage.
/**
* Prints usage information to stdout.
*/
private static void printUsage() {
HelpFormatter hf = new HelpFormatter();
StringBuilder header = new StringBuilder();
header.append("\nAvailable commands:\n");
// No args
addCmdHelp(header, "jobtracker", "Returns the jobtracker hostname and port");
addCmdHelp(header, "movejt", "Move the jobtracker and notifies the Task trakers");
String usage = String.format("java %s [-h|--host=<hostname>] [-p|--port=<#>] <command> <args>%n", BriskTool.class.getSimpleName());
hf.printHelp(usage, "", options, "");
System.out.println(header.toString());
}
use of org.apache.commons.cli.HelpFormatter in project f5less by sky87.
the class TheBuilder method main.
public static void main(String[] argv) throws Exception {
Options options = new Options();
options.addOption("js", false, "Create f5less.js");
options.addOption("p", "port", true, "ws:reload websocket server port");
options.addOption("h", "host", true, "ws:reload websocket server host");
options.addOption("d", "debounce", true, "debouncing for commands");
CommandLine cmdLine = new PosixParser().parse(options, argv);
String[] args = cmdLine.getArgs();
if (cmdLine.hasOption("js")) {
Files.copy(TheBuilder.class.getClassLoader().getResourceAsStream("f5less.js"), Paths.get("./f5less.js"), StandardCopyOption.REPLACE_EXISTING);
System.out.println("\n f5less.js created...\n put the following\n" + " <script type=\"text/javascript\" src=\"f5less.js\"></script>\n" + " <script type=\"text/javascript\">f5less.connect()</script>\n" + " in the page for which you want automatic reloading (assuming 'f5less.js' is in the same directory)\n");
}
if (args.length < 2) {
HelpFormatter formatter = new HelpFormatter();
formatter.printHelp("f5less [options] path1 cmd1 path2 cmd2 ...", options);
System.exit(-1);
}
final List<String> reloadPaths = new LinkedList<String>();
final int commandsDebounce = Integer.parseInt(cmdLine.getOptionValue("d", "100"));
for (int i = 0; i < args.length / 2; i++) {
final String path = args[i * 2];
final String rawCmd = args[i * 2 + 1];
if (rawCmd.equals("ws:reload"))
reloadPaths.add(path);
else
Watcher.register(path, new CommandListener(path, rawCmd, commandsDebounce));
}
ReloadServer reloadServer = null;
if (!reloadPaths.isEmpty()) {
reloadServer = new ReloadServer(cmdLine.getOptionValue("h", "localhost"), Integer.parseInt(cmdLine.getOptionValue("p", "9999")), commandsDebounce + 50);
reloadServer.monitor(reloadPaths);
}
System.out.println("Press enter to exit...");
System.in.read();
if (reloadServer != null)
reloadServer.stop();
Watcher.stop();
CommandListener.stop();
System.out.println("Bye bye");
}
use of org.apache.commons.cli.HelpFormatter in project flink by apache.
the class CliFrontendParser method printHelpForInfo.
public static void printHelpForInfo() {
HelpFormatter formatter = new HelpFormatter();
formatter.setLeftPadding(5);
formatter.setWidth(80);
System.out.println("\nAction \"info\" shows the optimized execution plan of the program (JSON).");
System.out.println("\n Syntax: info [OPTIONS] <jar-file> <arguments>");
formatter.setSyntaxPrefix(" \"info\" action options:");
formatter.printHelp(" ", getInfoOptionsWithoutDeprecatedOptions(new Options()));
printCustomCliOptions(formatter, false);
System.out.println();
}
use of org.apache.commons.cli.HelpFormatter in project flink by apache.
the class CliFrontendParser method printHelpForSavepoint.
public static void printHelpForSavepoint() {
HelpFormatter formatter = new HelpFormatter();
formatter.setLeftPadding(5);
formatter.setWidth(80);
System.out.println("\nAction \"savepoint\" triggers savepoints for a running job or disposes existing ones.");
System.out.println("\n Syntax: savepoint [OPTIONS] <Job ID> [<target directory>]");
formatter.setSyntaxPrefix(" \"savepoint\" action options:");
formatter.printHelp(" ", getSavepointOptionsWithoutDeprecatedOptions(new Options()));
printCustomCliOptions(formatter, false);
System.out.println();
}
Aggregations