List of usage examples for org.apache.commons.cli OptionBuilder withLongOpt
public static OptionBuilder withLongOpt(String newLongopt)
From source file:org.apache.sqoop.shell.ShowPrivilegeFunction.java
@SuppressWarnings("static-access") public ShowPrivilegeFunction() { this.addOption(OptionBuilder.withLongOpt(Constants.OPT_PRINCIPAL_TYPE) .withDescription(resourceString(Constants.RES_PROMPT_PRINCIPAL_TYPE)).hasArg().isRequired() .create());/*w w w. j av a 2 s . co m*/ this.addOption(OptionBuilder.withLongOpt(Constants.OPT_PRINCIPAL) .withDescription(resourceString(Constants.RES_PROMPT_PRINCIPAL)).hasArg().isRequired().create()); this.addOption(OptionBuilder.withLongOpt(Constants.OPT_RESOURCE_TYPE) .withDescription(resourceString(Constants.RES_PROMPT_RESOURCE_TYPE)).hasArg().create()); this.addOption(OptionBuilder.withLongOpt(Constants.OPT_RESOURCE) .withDescription(resourceString(Constants.RES_PROMPT_RESOURCE)).hasArg().create()); }
From source file:org.apache.sqoop.shell.ShowRoleFunction.java
@SuppressWarnings("static-access") public ShowRoleFunction() { this.addOption(OptionBuilder.withLongOpt(Constants.OPT_PRINCIPAL_TYPE) .withDescription(resourceString(Constants.RES_PROMPT_PRINCIPAL_TYPE)).hasArg().create()); this.addOption(OptionBuilder.withLongOpt(Constants.OPT_PRINCIPAL) .withDescription(resourceString(Constants.RES_PROMPT_PRINCIPAL)).hasArg().create()); }
From source file:org.apache.sqoop.shell.utils.ConfigOptions.java
/** * This method is used to automatically generate CLI options * for a particular config./* w ww .j a v a 2 s .c om*/ * * @param prefix Prefix to prepend to CLI option keys * @param config Config to get options for * @return List<Option> */ @SuppressWarnings({ "rawtypes", "static-access" }) public static List<Option> getConfigOptions(String prefix, MConfig config) { List<Option> options = new LinkedList<Option>(); for (MInput input : config.getInputs()) { if (input.getType().equals(MInputType.BOOLEAN)) { options.add(OptionBuilder.withLongOpt(getOptionKey(prefix, input)).create()); } else { options.add(OptionBuilder.withLongOpt(getOptionKey(prefix, input)).hasArg().create()); } } return options; }
From source file:org.apache.sqoop.shell.utils.JobDynamicConfigOptions.java
@SuppressWarnings("static-access") @Override//w ww. j av a2 s . co m public void prepareOptions(MJob job) { this.addOption(OptionBuilder.withLongOpt("name").hasArg().create()); for (Option option : ConfigOptions.getConfigsOptions("from", job.getJobConfig(Direction.FROM).getConfigs())) { this.addOption(option); } for (Option option : ConfigOptions.getConfigsOptions("driver", job.getDriverConfig().getConfigs())) { this.addOption(option); } for (Option option : ConfigOptions.getConfigsOptions("to", job.getJobConfig(Direction.TO).getConfigs())) { this.addOption(option); } }
From source file:org.apache.sqoop.shell.utils.LinkDynamicConfigOptions.java
@SuppressWarnings("static-access") @Override/*from w w w. j a v a 2s. c o m*/ public void prepareOptions(MLink link) { this.addOption(OptionBuilder.withLongOpt("name").hasArg().create()); for (Option option : ConfigOptions.getConfigsOptions("link", link.getConnectorLinkConfig().getConfigs())) { this.addOption(option); } }
From source file:org.apache.sqoop.tools.tool.RepositoryDumpTool.java
@Override public boolean runToolWithConfiguration(String[] arguments) { boolean skipSensitive = true; Options options = new Options(); options.addOption(OptionBuilder.withLongOpt("include-sensitive").withDescription( "Dump all data including sensitive information such as passwords. Passwords will be dumped in clear text") .create());//from www. j a v a2 s .co m options.addOption( OptionBuilder.isRequired().hasArg().withArgName("filename").withLongOpt("output").create('o')); CommandLineParser parser = new GnuParser(); try { CommandLine line = parser.parse(options, arguments); String outputFileName = line.getOptionValue('o'); if (line.hasOption("include-sensitive")) { skipSensitive = false; } BufferedWriter output = new BufferedWriter(new FileWriter(outputFileName)); LOG.info("Writing JSON repository dump to file " + outputFileName); dump(skipSensitive).writeJSONString(output); output.flush(); output.close(); } catch (ParseException e) { LOG.error("Error parsing command line arguments:", e); System.out.println("Error parsing command line arguments. Please check Server logs for details."); return false; } catch (IOException e) { LOG.error("Can't dump Sqoop repository to file:", e); System.out.println("Writing repository dump to file failed. Please check Server logs for details."); return false; } return true; }
From source file:org.apache.tapestry5.test.Jetty7Runner.java
/** * Main entrypoint used to run the Jetty7 instance from the command line. * * @since 5.4//w ww .j a v a2s. c o m */ public static void main(String[] args) throws Exception { String commandName = Jetty7Runner.class.getName(); Options options = new Options(); String webapp = "src/main/webapp"; String context = "/"; int httpPort = 8080; int sslPort = 8443; options.addOption(OptionBuilder.withLongOpt("directory") .withDescription("Root context directory (defaults to 'src/main/webapp')").hasArg() .withArgName("DIR").create('d')) .addOption(OptionBuilder.withLongOpt("context") .withDescription("Context path for application (defaults to '/')").hasArg() .withArgName("CONTEXT").create('c')) .addOption(OptionBuilder.withLongOpt("port").withDescription("HTTP port (defaults to 8080)") .hasArg().withArgName("PORT").create('p')) .addOption(OptionBuilder.withLongOpt("secure-port").withDescription("HTTPS port (defaults to 8443)") .hasArg().withArgName("PORT").create('s')) .addOption("h", "help", false, "Display command usage"); CommandLine line = new BasicParser().parse(options, args); boolean usage = line.hasOption('h'); if (!usage) { if (line.hasOption('d')) { webapp = line.getOptionValue('d'); } File folder = new File(webapp); if (!folder.exists()) { System.err.printf("%s: Directory `%s' does not exist.%n", commandName, webapp); System.exit(-1); } if (line.hasOption('p')) { try { httpPort = Integer.parseInt(line.getOptionValue('p')); } catch (NumberFormatException e) { usage = true; } } if (line.hasOption('s')) { try { sslPort = Integer.parseInt(line.getOptionValue('s')); } catch (NumberFormatException e) { usage = true; } } if (line.hasOption('c')) { context = line.getOptionValue('c'); } } if (usage) { new HelpFormatter().printHelp(commandName, options); System.exit(-1); } new Jetty7Runner(webapp, context, httpPort, sslPort); }
From source file:org.apache.tapestry5.test.JettyRunner.java
/** * Main entrypoint used to run the Jetty instance from the command line. * * @since 5.4//from w ww. ja v a 2s .c om */ public static void main(String[] args) throws Exception { String commandName = JettyRunner.class.getName(); Options options = new Options(); String webapp = "src/main/webapp"; String context = "/"; int httpPort = 8080; int sslPort = 8443; options.addOption(OptionBuilder.withLongOpt("directory") .withDescription("Root context directory (defaults to 'src/main/webapp')").hasArg() .withArgName("DIR").create('d')) .addOption(OptionBuilder.withLongOpt("context") .withDescription("Context path for application (defaults to '/')").hasArg() .withArgName("CONTEXT").create('c')) .addOption(OptionBuilder.withLongOpt("port").withDescription("HTTP port (defaults to 8080)") .hasArg().withArgName("PORT").create('p')) .addOption(OptionBuilder.withLongOpt("secure-port").withDescription("HTTPS port (defaults to 8443)") .hasArg().withArgName("PORT").create('s')) .addOption("h", "help", false, "Display command usage"); CommandLine line = new BasicParser().parse(options, args); boolean usage = line.hasOption('h'); if (!usage) { if (line.hasOption('d')) { webapp = line.getOptionValue('d'); } File folder = new File(webapp); if (!folder.exists()) { System.err.printf("%s: Directory `%s' does not exist.%n", commandName, webapp); System.exit(-1); } if (line.hasOption('p')) { try { httpPort = Integer.parseInt(line.getOptionValue('p')); } catch (NumberFormatException e) { usage = true; } } if (line.hasOption('s')) { try { sslPort = Integer.parseInt(line.getOptionValue('s')); } catch (NumberFormatException e) { usage = true; } } if (line.hasOption('c')) { context = line.getOptionValue('c'); } } if (usage) { new HelpFormatter().printHelp(commandName, options); System.exit(-1); } new JettyRunner(webapp, context, httpPort, sslPort); }
From source file:org.apache.usergrid.launcher.Server.java
static Options createOptions() { // the nogui option will be required due to combining the graphical // launcher with this standalone CLI based server Options options = new Options(); OptionBuilder.withDescription("Start launcher without UI"); OptionBuilder.isRequired(true);/* w ww . java 2 s . c o m*/ Option noguiOption = OptionBuilder.create("nogui"); OptionBuilder.isRequired(false); OptionBuilder.withDescription("Initialize database"); Option initOption = OptionBuilder.create("init"); OptionBuilder.withDescription("Start database"); Option dbOption = OptionBuilder.create("db"); OptionBuilder.withDescription("Http port (without UI)"); OptionBuilder.hasArg(); OptionBuilder.withArgName("PORT"); OptionBuilder.withLongOpt("port"); OptionBuilder.withType(Number.class); Option portOption = OptionBuilder.create('p'); options.addOption(initOption); options.addOption(dbOption); options.addOption(portOption); options.addOption(noguiOption); return options; }
From source file:org.appdynamics.licensecount.resources.LicenseOptions.java
public static void init() { Option controller = OptionBuilder.withLongOpt(LicenseS.CONTROLLER_L).withArgName(LicenseS.CONTROLLER_S) .hasArg().withDescription(LicenseS.CONTROLLER_D).create(LicenseS.CONTROLLER_S); options.addOption(controller);//from w ww.j a va 2 s. c o m Option port = OptionBuilder.withLongOpt(LicenseS.PORT_L).withArgName(LicenseS.PORT_S).hasArg() .withDescription(LicenseS.PORT_D).create(LicenseS.PORT_S); options.addOption(port); Option account = OptionBuilder.withLongOpt(LicenseS.ACCOUNT_L).withArgName(LicenseS.ACCOUNT_S).hasArg() .withDescription(LicenseS.ACCOUNT_D).create(LicenseS.ACCOUNT_S); options.addOption(account); Option username = OptionBuilder.withLongOpt(LicenseS.USERNAME_L).withArgName(LicenseS.USERNAME_S).hasArg() .withDescription(LicenseS.USERNAME_D).create(LicenseS.USERNAME_S); options.addOption(username); Option passwd = OptionBuilder.withLongOpt(LicenseS.PASSWD_L).withArgName(LicenseS.PASSWD_S).hasArg() .withDescription(LicenseS.PASSWD_D).create(LicenseS.PASSWD_S); options.addOption(passwd); options.addOption(LicenseS.SSL_S, LicenseS.SSL_L, LicenseS.SSL_A, LicenseS.SSL_D); options.addOption(LicenseS.NOW_S, LicenseS.NOW_L, LicenseS.NOW_A, LicenseS.NOW_D); Option debug = OptionBuilder.withLongOpt(LicenseS.DEBUG_L).withArgName(LicenseS.DEBUG_S).hasArg() .withDescription(LicenseS.DEBUG_D).create(LicenseS.DEBUG_S); options.addOption(debug); options.addOption(LicenseS.GRANULAR_S, LicenseS.GRANULAR_L, LicenseS.GRANULAR_A, LicenseS.GRANULAR_D); /* Filename & Interval */ Option filename = OptionBuilder.withLongOpt(LicenseS.FILENAME_L).withArgName(LicenseS.FILENAME_S).hasArg() .withDescription(LicenseS.FILENAME_D).create(LicenseS.FILENAME_S); options.addOption(filename); Option interval = OptionBuilder.withLongOpt(LicenseS.INTERVAL_L).withArgName(LicenseS.INTERVAL_S).hasArg() .withDescription(LicenseS.INTERVAL_D).create(LicenseS.INTERVAL_S); options.addOption(interval); Option uptime = OptionBuilder.withLongOpt(LicenseS.UPTIME_L).withArgName(LicenseS.UPTIME_S).hasArg() .withDescription(LicenseS.UPTIME_D).create(LicenseS.UPTIME_S); options.addOption(uptime); Option apps = OptionBuilder.withLongOpt(LicenseS.APPS_L).withArgName(LicenseS.APPS_S).hasArg() .withDescription(LicenseS.APPS_D).create(LicenseS.APPS_S); options.addOption(apps); Option group = OptionBuilder.withLongOpt(LicenseS.GROUP_L).withArgName(LicenseS.GROUP_S).hasArg() .withDescription(LicenseS.GROUP_D).create(LicenseS.GROUP_S); options.addOption(group); }