List of usage examples for org.apache.commons.cli HelpFormatter setWidth
public void setWidth(int width)
From source file:org.apache.nifi.toolkit.s2s.SiteToSiteCliMain.java
/** * Prints the usage to System.out/* ww w. ja va 2 s . c om*/ * * @param errorMessage optional error message * @param options the options object to print usage for */ public static void printUsage(String errorMessage, Options options) { if (errorMessage != null) { System.out.println(errorMessage); System.out.println(); System.out.println(); } ObjectMapper objectMapper = new ObjectMapper(); objectMapper.disable(JsonGenerator.Feature.AUTO_CLOSE_TARGET); objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); System.out.println( "s2s is a command line tool that can either read a list of DataPackets from stdin to send over site-to-site or write the received DataPackets to stdout"); System.out.println(); System.out.println( "The s2s cli input/output format is a JSON list of DataPackets. They can have the following formats:"); try { System.out.println(); objectMapper.writeValue(System.out, Arrays.asList( new DataPacketDto("hello nifi".getBytes(StandardCharsets.UTF_8)).putAttribute("key", "value"))); System.out.println(); System.out.println( "Where data is the base64 encoded value of the FlowFile content (always used for received data) or"); System.out.println(); objectMapper.writeValue(System.out, Arrays.asList(new DataPacketDto(new HashMap<>(), new File("EXAMPLE").getAbsolutePath()) .putAttribute("key", "value"))); System.out.println(); System.out.println("Where dataFile is a file to read the FlowFile content from"); System.out.println(); System.out.println(); System.out.println( "Example usage to send a FlowFile with the contents of \"hey nifi\" to a local unsecured NiFi over http with an input port named input:"); System.out.print("echo '"); DataPacketDto dataPacketDto = new DataPacketDto("hey nifi".getBytes(StandardCharsets.UTF_8)); dataPacketDto.setAttributes(null); objectMapper.writeValue(System.out, Arrays.asList(dataPacketDto)); System.out.println("' | bin/s2s.sh -n input -p http"); System.out.println(); } catch (IOException e) { e.printStackTrace(); } HelpFormatter helpFormatter = new HelpFormatter(); helpFormatter.setWidth(160); helpFormatter.printHelp("s2s", options); System.out.flush(); }
From source file:org.apache.nifi.toolkit.tls.commandLine.BaseCommandLine.java
public void printUsage(String errorMessage) { if (errorMessage != null) { System.out.println(errorMessage); System.out.println();/*www . j a va 2 s. com*/ } HelpFormatter helpFormatter = new HelpFormatter(); helpFormatter.setWidth(160); helpFormatter.printHelp(TlsToolkitMain.class.getCanonicalName(), header, options, FOOTER, true); }
From source file:org.apache.nifi.toolkit.zkmigrator.ZooKeeperMigratorMain.java
private static void printUsage(String errorMessage, Options options) { Preconditions.checkNotNull(options, "command line options were not specified"); if (errorMessage != null) { System.out.println(errorMessage + System.lineSeparator()); }// w w w. ja va2 s . co m HelpFormatter helpFormatter = new HelpFormatter(); helpFormatter.setWidth(160); helpFormatter.setDescPadding(0); helpFormatter.printHelp(ZooKeeperMigratorMain.class.getCanonicalName(), HEADER, options, FOOTER, true); }
From source file:org.apache.pirk.querier.wideskies.QuerierCLI.java
/** * Prints out the help message//w w w. j a v a 2s.c om */ private void printHelp() { HelpFormatter formatter = new HelpFormatter(); formatter.setWidth(140); formatter.printHelp("QuerierDriver", cliOptions); }
From source file:org.apache.pirk.responder.wideskies.ResponderCLI.java
/** * Prints out the help message//from ww w. j a v a 2s .c o m */ private void printHelp() { HelpFormatter formatter = new HelpFormatter(); formatter.setWidth(140); formatter.printHelp("ResponderDriver", cliOptions); }
From source file:org.apache.pirk.test.distributed.DistributedTestCLI.java
/** * Prints out the help message/*from w w w . j av a2 s. c o m*/ */ private void printHelp() { HelpFormatter formatter = new HelpFormatter(); formatter.setWidth(140); formatter.printHelp("DistributedTestDriver", cliOptions); }
From source file:org.apache.tez.history.ATSImportTool.java
static void printHelp(Options options) { HelpFormatter formatter = new HelpFormatter(); formatter.setWidth(240); String help = LINE_SEPARATOR//from ww w.ja v a 2 s . co m + "java -cp tez-history-parser-x.y.z-jar-with-dependencies.jar org.apache.tez.history.ATSImportTool" + LINE_SEPARATOR + "OR" + LINE_SEPARATOR + "HADOOP_CLASSPATH=$TEZ_HOME/*:$TEZ_HOME/lib/*:$HADOOP_CLASSPATH hadoop jar " + "tez-history-parser-x.y.z.jar " + ATSImportTool.class.getName() + LINE_SEPARATOR; formatter.printHelp(240, help, "Options", options, "", true); }
From source file:org.apache.tez.history.ATSImportTool_V2.java
static void printHelp(Options options) { HelpFormatter formatter = new HelpFormatter(); formatter.setWidth(240); String help = LINE_SEPARATOR/* ww w. j av a 2 s.c o m*/ + "java -cp tez-ats-import-0.8.0-SNAPSHOT.jar org.apache.tez.history.ATSImportTool" + LINE_SEPARATOR + "OR" + LINE_SEPARATOR + " yarn jar tez-ats-import-0.8.0-SNAPSHOT.jar" + LINE_SEPARATOR; formatter.printHelp(240, help, "Options", options, "", true); }
From source file:org.diksha.client.DikshaCli.java
public static void main(String[] args) { CommandLine commandLine;//from w ww. ja v a 2 s . c o m Options options = new Options(); CommandLineParser parser = new GnuParser(); options.addOption(Option.builder("admcd").longOpt("admin-create-domain").desc("create domain").hasArgs() .valueSeparator('|').build()); options.addOption(Option.builder("admdd").longOpt("admin-deprecate-domain").desc("deprecate domain") .hasArgs().valueSeparator('|').build()); options.addOption(Option.builder("admcdt").longOpt("admin-create-dynano-tables") .desc("helper to create dynamotables").hasArgs().valueSeparator('|').build()); options.addOption(Option.builder("admddt").longOpt("admin-delete-dynano-tables") .desc("helper to delete dynamotables").hasArgs().valueSeparator('|').build()); options.addOption(Option.builder("admcspa").longOpt("admin-create-security-policy-admin") .desc("create security policy admin").hasArg().build()); options.addOption(Option.builder("admdspa").longOpt("admin-delete-security-policy-admin") .desc("delete security policy admin").hasArg().build()); options.addOption(Option.builder("admcspd").longOpt("admin-create-security-policy-designer") .desc("create security policy designer").hasArg().build()); options.addOption(Option.builder("admdspd").longOpt("admin-delete-security-policy-designer") .desc("delete security policy designer").hasArg().build()); options.addOption(Option.builder("admcspu").longOpt("admin-create-security-policy-user") .desc("create security policy user").hasArg().build()); options.addOption(Option.builder("admdspu").longOpt("admin-delete-security-policy-user") .desc("delete security policy user").hasArg().build()); options.addOption(Option.builder("admcspw").longOpt("admin-create-security-policy-workflow") .desc("create security policy workflow").hasArg().build()); options.addOption(Option.builder("admdspw").longOpt("admin-delete-security-policy-workflow") .desc("delete security policy workflow").hasArg().build()); options.addOption(Option.builder("admcsga").longOpt("admin-create-security-group-admin") .desc("create security group admin").hasArg().build()); options.addOption(Option.builder("admdsga").longOpt("admin-delete-security-group-admin") .desc("delete security group admin").hasArg().build()); options.addOption(Option.builder("admcsgd").longOpt("admin-create-security-group-designer") .desc("create security group designer").hasArg().build()); options.addOption(Option.builder("admdsgd").longOpt("admin-delete-security-group-designer") .desc("delete security group designer").hasArg().build()); options.addOption(Option.builder("admcsgu").longOpt("admin-create-security-group-user") .desc("create security group user").hasArg().build()); options.addOption(Option.builder("admdsgu").longOpt("admin-delete-security-group-user") .desc("delete security group user").hasArg().build()); options.addOption(Option.builder("admcsgw").longOpt("admin-create-security-group-workflow") .desc("create security group workflow").hasArg().build()); options.addOption(Option.builder("admdsgw").longOpt("admin-delete-security-group-workflow") .desc("delete security group workflow").hasArg().build()); options.addOption(Option.builder("cf").longOpt("create-function").desc( "helper to create a refernce to a function in scheduler -cf cool|L|arn:aws:lambda:us-east-1:709574751419:function:echocool") .hasArgs().valueSeparator('|').build()); options.addOption(Option.builder("df").longOpt("delete-function") .desc("helper to delete the refernce to a function created by -cf option in scheduler").hasArg() .build()); options.addOption(Option.builder("lfs").longOpt("list-functions") .desc("helper to list all the refeences to functions created by -cf option in scheduler").build()); options.addOption(Option.builder("ef").longOpt("execute-function").desc( "option to execute a raw function in scheduler -lcfg cf1 -ef L|arn:aws:lambda:us-east-1:123456789012:function:echocool|somecontext|0 0-59 * * * *|3|24.07.2015T14:34:00-0700|24.07.2015T14:36:00-0700") .hasArgs().valueSeparator('|').build()); // configid|endPoint|domain|socketTimeout|taskList // config1|https://swf.us-east-1.amazonaws.com|helloWorldWalkthrough|70000|HelloWorldList options.addOption(Option.builder("ccfg").longOpt("create-config").desc( "create a configurration in scheduler...config1|https://swf.us-east-1.amazonaws.com|helloWorldWalkthrough|70000|HelloWorldList") .hasArgs().valueSeparator('|').build()); options.addOption(Option.builder("lcfg").longOpt("load-config").desc("load a configurration in scheduler.") .hasArgs().valueSeparator('|').build()); options.addOption(Option.builder("cj").longOpt("create-job").desc( "create a refernce to a job in scheduler --- -cj runcooljobeverymin|cool|contextmin|0 0-59 * * * *|2") .hasArgs().valueSeparator('|').build()); options.addOption(Option.builder("dj").longOpt("delete-job") .desc("delete a refernce to a job created by -cj option in scheduler").hasArg().build()); options.addOption(Option.builder("ljs").longOpt("list-jobs") .desc("list all the jobs loaded in the schedule for the job to run in scheduler").build()); options.addOption(Option.builder("ej").longOpt("execute-job") .desc("execute the schedule for the job to run in scheduler").hasArg().build()); options.addOption( Option.builder("laes").longOpt("list-active-jobs").desc("list active jobs in scheduler").build()); options.addOption( Option.builder("eid").longOpt("execution-id").desc("execution id if known").hasArg().build()); options.addOption(Option.builder("rcon").longOpt("reconcile") .desc("reconcile active executions in Scheduler to what is reported in AWS scheduler").build()); options.addOption(Option.builder("rrep").longOpt("reconcile-report") .desc("reconcile report on open executions in Scheduler to what is reported in AWS scheduler") .build()); options.addOption(Option.builder("rfix").longOpt("reconcile-fix") .desc("reconcile fix executions in Scheduler to what is reported in AWS scheduler").build()); options.addOption(Option.builder("lse").longOpt("list-status-execution") .desc("list status for specifed exection to run in scheduler").hasArg().build()); options.addOption(Option.builder("cane").longOpt("cancel-execution") .desc("option to cancel an existing execution in scheduler args: clientId|reason").hasArgs() .valueSeparator('|').build()); options.addOption(Option.builder("h").longOpt("help").desc("help").build()); String header = "The commandline driver for DyDBTest\n\n"; String footer = "\nPlease report issues at http://github.com/milindparikh/cronaws/issues"; try { commandLine = parser.parse(options, args); if (commandLine.hasOption("admcdt")) { String[] tables = commandLine.getOptionValues("admcdt"); DyDBUtils.createDynamoTables(tables); } if (commandLine.hasOption("admddt")) { String[] tables = commandLine.getOptionValues("admddt"); DyDBUtils.deleteDynamoTables(tables); } if (commandLine.hasOption("admcd")) { String[] domainArgs = commandLine.getOptionValues("admcd"); SWFUtils.createDomain(domainArgs); } if (commandLine.hasOption("admdd")) { String domainName = commandLine.getOptionValue("admdd"); SWFUtils.deprecateDomain(domainName); } if (commandLine.hasOption("cf")) { String[] functionArgs = commandLine.getOptionValues("cf"); DyDBUtils.createFunction(functionArgs); } if (commandLine.hasOption("lfs")) { DyDBUtils.listFunctions(); } if (commandLine.hasOption("df")) { String functionAlias = commandLine.getOptionValue("df"); DyDBUtils.deleteFunction(functionAlias); } if (commandLine.hasOption("ccfg")) { DyDBUtils.createSchedulerConfig(commandLine.getOptionValues("ccfg")); } if (commandLine.hasOption("rcon")) { DyDBUtils.reconcile(commandLine.getOptionValue("lcfg")); } if (commandLine.hasOption("rrep")) { DyDBUtils.reconcileReport(commandLine.getOptionValue("lcfg")); } if (commandLine.hasOption("rfix")) { DyDBUtils.reconcileFix(commandLine.getOptionValue("lcfg")); } if (commandLine.hasOption("lse")) { DyDBUtils.listStatusExecution(commandLine.getOptionValue("lcfg"), commandLine.getOptionValue("lse")); } if (commandLine.hasOption("cane")) { DyDBUtils.cancelExecution(commandLine.getOptionValue("lcfg"), commandLine.getOptionValues("cane")); } if (commandLine.hasOption("ef")) { DyDBUtils.executeFunction(commandLine.getOptionValue("lcfg"), commandLine.getOptionValues("ef")); } if (commandLine.hasOption("cj")) { String[] jobArgs = commandLine.getOptionValues("cj"); DyDBUtils.createJob(jobArgs); } if (commandLine.hasOption("dj")) { String jobName = commandLine.getOptionValue("dj"); DyDBUtils.deleteJob(jobName); } if (commandLine.hasOption("ljs")) { DyDBUtils.listJobs(); } if (commandLine.hasOption("ej")) { String jobName = commandLine.getOptionValue("ej"); DyDBUtils.executeJob(commandLine.getOptionValue("lcfg"), jobName); } if (commandLine.hasOption("laes")) { DyDBUtils.listActiveJobs(commandLine.getOptionValue("eid")); } if (commandLine.hasOption("admcspa")) { IAMUtils.createSecurityPolicyAdmin(commandLine.getOptionValue("admcspa")); } if (commandLine.hasOption("admdspa")) { IAMUtils.deleteSecurityPolicyAdmin(commandLine.getOptionValue("admdspa")); } if (commandLine.hasOption("admcsga")) { String[] args1 = commandLine.getOptionValue("admcsga").split(","); String groupName = args1[0]; String policyName = args1[1]; IAMUtils.createSecurityGroup(groupName, policyName); } if (commandLine.hasOption("admdsga")) { IAMUtils.deleteSecurityGroup(commandLine.getOptionValue("admdsga")); } if (commandLine.hasOption("admcspd")) { IAMUtils.createSecurityPolicyDesigner(commandLine.getOptionValue("admcspd")); } if (commandLine.hasOption("admdspd")) { IAMUtils.deleteSecurityPolicyDesigner(commandLine.getOptionValue("admdspd")); } if (commandLine.hasOption("admcsgd")) { String[] args1 = commandLine.getOptionValue("admcsgd").split(","); String groupName = args1[0]; String policyName = args1[1]; IAMUtils.createSecurityGroup(groupName, policyName); } if (commandLine.hasOption("admdsgd")) { IAMUtils.deleteSecurityGroup(commandLine.getOptionValue("admdsgd")); } if (commandLine.hasOption("admcspu")) { IAMUtils.createSecurityPolicyUser(commandLine.getOptionValue("admcspu")); } if (commandLine.hasOption("admdspu")) { IAMUtils.deleteSecurityPolicyUser(commandLine.getOptionValue("admdspu")); } if (commandLine.hasOption("admcsgu")) { String[] args1 = commandLine.getOptionValue("admcsgu").split(","); String groupName = args1[0]; String policyName = args1[1]; IAMUtils.createSecurityGroup(groupName, policyName); } if (commandLine.hasOption("admdsgu")) { IAMUtils.deleteSecurityGroup(commandLine.getOptionValue("admdsgu")); } if (commandLine.hasOption("admcspw")) { IAMUtils.createSecurityPolicyWorkflow(commandLine.getOptionValue("admcspw")); } if (commandLine.hasOption("admdspw")) { IAMUtils.deleteSecurityPolicyWorkflow(commandLine.getOptionValue("admdspw")); } if (commandLine.hasOption("admcsgw")) { String[] args1 = commandLine.getOptionValue("admcsgw").split(","); String groupName = args1[0]; String policyName = args1[1]; IAMUtils.createSecurityGroup(groupName, policyName); } if (commandLine.hasOption("admdsgw")) { IAMUtils.deleteSecurityGroup(commandLine.getOptionValue("admdsgw")); } if (commandLine.hasOption("h")) { HelpFormatter formatter = new HelpFormatter(); formatter.setWidth(100); formatter.printHelp("DyDBTest", header, options, footer, true); } } catch (ParseException exception) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("DyDBTest", header, options, footer, true); } }
From source file:org.duracloud.chunk.FileChunkerDriver.java
private static void usage() { HelpFormatter help = new HelpFormatter(); help.setWidth(80); help.printHelp(FileChunker.class.getCanonicalName(), getOptions()); }