当前位置: 首页>>代码示例>>Java>>正文


Java HelpFormatter.printHelp方法代码示例

本文整理汇总了Java中org.apache.commons.cli.HelpFormatter.printHelp方法的典型用法代码示例。如果您正苦于以下问题:Java HelpFormatter.printHelp方法的具体用法?Java HelpFormatter.printHelp怎么用?Java HelpFormatter.printHelp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.cli.HelpFormatter的用法示例。


在下文中一共展示了HelpFormatter.printHelp方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: printHelp

import org.apache.commons.cli.HelpFormatter; //导入方法依赖的package包/类
/**
 * Print help/usage information.
 *
 * @param message the message or null for none
 */
private void printHelp(final String message) {
    final HelpFormatter formatter = new HelpFormatter();
    final PrintWriter writer = new PrintWriter(out);
    if (message != null) {
        writer.println("\n-----------------------\n" + message + "\n-----------------------\n");
    }
    writer.println("Running IIIF Producer from command line arguments");
    formatter.printHelp(writer, 80, "java -jar IIIFProducer.jar", "", configOptions, 4, 4, "",
            true);
    writer.println("\n");
    writer.flush();

    if (message != null) {
        throw new RuntimeException(message);
    } else {
        throw new RuntimeException();
    }
}
 
开发者ID:ubleipzig,项目名称:iiif-producer,代码行数:24,代码来源:ArgParser.java

示例2: main

import org.apache.commons.cli.HelpFormatter; //导入方法依赖的package包/类
public static void main(String[] args) {
    CommandLineParser parser = new DefaultParser();
    try {
        Options options = getOptions();
        CommandLine line = parser.parse(options, args );
        if (line.hasOption("help")) {
            HelpFormatter formatter = new HelpFormatter();
            System.out.println(Constants.PROJECT_NAME + ", " + Constants.PROJECT_URL);
            formatter.printHelp(Constants.PROJECT_NAME, options, true);
        } else if (line.hasOption("version")) {
            System.out.println("version: " + Constants.VERSION);
        } else {
            logger.info("Starting pm-home-station ({} v.{})...", Constants.PROJECT_URL, Constants.VERSION);
            setLookAndFeel();
            PlanTowerSensor planTowerSensor = new PlanTowerSensor();
            Station station = new Station(planTowerSensor);
            SwingUtilities.invokeLater(() -> { station.showUI(); });
        }
    } catch (ParseException e) {
        logger.error("Ooops", e);
        return;
    }
}
 
开发者ID:rjaros87,项目名称:pm-home-station,代码行数:24,代码来源:Start.java

示例3: main

import org.apache.commons.cli.HelpFormatter; //导入方法依赖的package包/类
public static void main(String[] args) {

    Options options = new Options();
    options.addOption("h", true, "Messaging host");
    options.addOption("p", true, "Messaging port");
    options.addOption("q", true, "Queue");
    options.addOption("u", false, "Print this help");

    CommandLineParser parser = new DefaultParser();

    try {

      CommandLine cmd = parser.parse(options, args);

      if (cmd.hasOption("u")) {

        HelpFormatter helpFormatter = new HelpFormatter();
        helpFormatter.printHelp("Sender", options);

      } else {

        String messagingHost = cmd.getOptionValue("h", MESSAGING_HOST);
        int messagingPort = Integer.parseInt(cmd.getOptionValue("p", String.valueOf(MESSAGING_PORT)));
        String address = cmd.getOptionValue("q", QUEUE);

        Properties props = new Properties();
        props.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.qpid.jms.jndi.JmsInitialContextFactory");
        props.put("connectionfactory.myFactoryLookup", String.format("amqp://%s:%d", messagingHost, messagingPort));
        props.put("queue.myDestinationLookup", address);

        LOG.info("Starting server : connecting to [{}:{}]", messagingHost, messagingPort);

        Server sender = new Server();
        sender.run(props);
      }

    } catch (ParseException e) {
      e.printStackTrace();
    }
  }
 
开发者ID:ppatierno,项目名称:amqp-kafka-demo,代码行数:41,代码来源:Server.java

示例4: main

import org.apache.commons.cli.HelpFormatter; //导入方法依赖的package包/类
public static void main(String[] args) {
    Options options = getOptions();
    CommandLine cmd = null;
    try {
        cmd = parseCommandLineArgs(options, args);
    } catch (ParseException e) {
        System.out.format("%s.%n", e.getMessage());
        final HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp("ConsoleReader", options);
        System.exit(1);
    }
    
    final String scope = cmd.getOptionValue("scope") == null ? Constants.DEFAULT_SCOPE : cmd.getOptionValue("scope");
    final String streamName = cmd.getOptionValue("name") == null ? Constants.DEFAULT_STREAM_NAME : cmd.getOptionValue("name");
    final String uriString = cmd.getOptionValue("uri") == null ? Constants.DEFAULT_CONTROLLER_URI : cmd.getOptionValue("uri");
    final URI controllerURI = URI.create(uriString);
    
    ConsoleReader reader = new ConsoleReader(scope, streamName, controllerURI);
    reader.run();
}
 
开发者ID:pravega,项目名称:pravega-samples,代码行数:21,代码来源:ConsoleReader.java

示例5: parseGeneralOptions

import org.apache.commons.cli.HelpFormatter; //导入方法依赖的package包/类
/**
 * Parse the user-specified options, get the generic options, and modify
 * configuration accordingly
 * @param opts Options to use for parsing args.
 * @param conf Configuration to be modified
 * @param args User-specified arguments
 */
private void parseGeneralOptions(Options opts, Configuration conf, 
    String[] args) throws IOException {
  opts = buildGeneralOptions(opts);
  CommandLineParser parser = new GnuParser();
  try {
    commandLine = parser.parse(opts, preProcessForWindows(args), true);
    processGeneralOptions(conf, commandLine);
  } catch(ParseException e) {
    LOG.warn("options parsing failed: "+e.getMessage());

    HelpFormatter formatter = new HelpFormatter();
    formatter.printHelp("general options are: ", opts);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:22,代码来源:GenericOptionsParser.java

示例6: printUsageAndExit

import org.apache.commons.cli.HelpFormatter; //导入方法依赖的package包/类
private static void printUsageAndExit(Options options, int exitCode) {
  HelpFormatter formatter = new HelpFormatter();
  formatter.printHelp("bin/hbase rest start", "", options,
    "\nTo run the REST server as a daemon, execute " +
    "bin/hbase-daemon.sh start|stop rest [--infoport <port>] [-p <port>] [-ro]\n", true);
  System.exit(exitCode);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:8,代码来源:RESTServer.java

示例7: printHelp

import org.apache.commons.cli.HelpFormatter; //导入方法依赖的package包/类
public void printHelp() {
    HelpFormatter formatter = new HelpFormatter();
    formatter.setSyntaxPrefix("Usage: ");
    formatter.setOptionComparator(null);

    String columns = System.getenv(ENV_COLUMNS);
    if (columns != null) {
        try {
            formatter.setWidth(Integer.parseInt(columns));
        } catch (Exception e) {
            logger.warn(e.toString());
        }
    }

    String header = "Run the " + VersionInfo.PRODUCT + " standalone command-line application.\n\n";
    String leftPadding = StringUtils.repeat(' ', formatter.getLeftPadding());
    //@formatter:off
    String footer = new StringBuilder()
            .append("\nExamples (change directory to " + VersionInfo.PRODUCT + " bin/ first):\n")
            .append(leftPadding + "./" + EXECUTABLE_NAME + " -c ../examples/script/py/hello_world.xml\n")
            .append(leftPadding + "./" + EXECUTABLE_NAME + " -k helloWorldKb=../examples/script/py/hello_world.py\n")
            .append(leftPadding + "./" + EXECUTABLE_NAME + " -k ../examples/script/py/hello_world.py\n")
            .append(leftPadding + "./" + EXECUTABLE_NAME
                    + " -k filtersKb=../examples/script/py/filters.py -k heartbeatKb=../examples/script/js/rules_heartbeat.js\n")
            .append(leftPadding + "./" + EXECUTABLE_NAME
                    + " -k ../examples/standalone/multiple_kb_files/event_processors.py"
                    + ",../examples/standalone/multiple_kb_files/example2.py\n")
            .append("\nPress CTRL+C to exit the " + VersionInfo.PRODUCT + " standalone command-line application.\n")
            .append("\nSee http://sponge.openksavi.org for more details.").toString();
    //@formatter:on
    formatter.printHelp(EXECUTABLE_NAME, header, options, footer, true);
}
 
开发者ID:softelnet,项目名称:sponge,代码行数:33,代码来源:StandaloneEngineBuilder.java

示例8: printUsageAndExit

import org.apache.commons.cli.HelpFormatter; //导入方法依赖的package包/类
private static void printUsageAndExit(Options options, int exitCode)
    throws ExitCodeException {
  HelpFormatter formatter = new HelpFormatter();
  formatter.printHelp("Thrift", null, options,
      "To start the Thrift server run 'bin/hbase-daemon.sh start thrift'\n" +
      "To shutdown the thrift server run 'bin/hbase-daemon.sh stop " +
      "thrift' or send a kill signal to the thrift server pid",
      true);
  throw new ExitCodeException(exitCode, "");
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:11,代码来源:ThriftServer.java

示例9: outputHelp

import org.apache.commons.cli.HelpFormatter; //导入方法依赖的package包/类
/**
 * Outputs the formatted help to standard out
 */
void outputHelp() {
  if (!shouldOutputHelp()) {
    return;
  }
  if (source != null) {
    HelpFormatter hlp = new HelpFormatter();
    hlp.printHelp(Constants.PROG_NAME + " " + Constants.PROG_VERSION,
        source.getOptionList());
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:14,代码来源:ArgumentParser.java

示例10: printHelp

import org.apache.commons.cli.HelpFormatter; //导入方法依赖的package包/类
/**
 * Generate help information with Apache Commons CLI.
 *
 * @param options Instance of Options to be used to prepare
 *    help formatter.
 * @return HelpFormatter instance that can be used to print
 *    help information.
 */
private static void printHelp(final Options options)
{
   final HelpFormatter formatter = new HelpFormatter();
   final String syntax = "Main";
   final String usageHeader = "Example of Using Apache Commons CLI";
   final String usageFooter = "See http://marxsoftware.blogspot.com/ for further details.";
   out.println("\n====");
   out.println("HELP");
   out.println("====");
   formatter.printHelp(syntax, usageHeader, options, usageFooter);
}
 
开发者ID:dustinmarx,项目名称:java-cli-demos,代码行数:20,代码来源:MainWithBuilder.java

示例11: main

import org.apache.commons.cli.HelpFormatter; //导入方法依赖的package包/类
public static void main(String[] args) {
	//les paramètres
	String nameSerie = null;
	String nameMention = null;
	String nameOption = null;
	String nameEuro = null;
	String dburi = null;
	String dbuser = null;
	String dbpwd = null;
	
	//les options de la ligne de commande
	Options options = new Options();
	Option serie = new Option("s", "serie", true, "série à exporter");
	serie.setRequired(true);
	options.addOption(serie);
	Option mention = new Option("m", "mention", true, "mention à exporter");
	mention.setRequired(true);
	options.addOption(mention);
	Option option = new Option("o", "option", true, "spécialité à exporter");
	option.setRequired(true);
	options.addOption(option);
	Option euro = new Option("e", "euro", true, "section à exporter");
	euro.setRequired(true);
	options.addOption(euro);
	Option uri = new Option("r", "uri", true, "uri de la bd");
	uri.setRequired(true);
	options.addOption(uri);
	Option user = new Option("u", "user", true, "nom utilisateur");
	user.setRequired(true);
	options.addOption(user);
	Option pwd = new Option("p", "password", true, "mot de passe utilisateur");
	pwd.setRequired(true);
	options.addOption(pwd);

	//parser la ligne de commande
    CommandLineParser parser = new DefaultParser();
    try {
        CommandLine line = parser.parse( options, args );
        if (line.hasOption("s")) {
			nameSerie = line.getOptionValue("s");
		}
        if (line.hasOption("m")) {
			nameMention = line.getOptionValue("m");
		}
        if (line.hasOption("o")) {
			nameOption = line.getOptionValue("o");
		}
        if (line.hasOption("e")) {
			nameEuro = line.getOptionValue("e");
		}
        if (line.hasOption("r")) {
			dburi = line.getOptionValue("r");
		}
        if (line.hasOption("u")) {
			dbuser = line.getOptionValue("u");
		}
        if (line.hasOption("p")) {
			dbpwd = line.getOptionValue("p");
		}
    }
    catch( ParseException exp ) {
    	LOG.severe("Erreur dans la ligne de commande");
    	HelpFormatter formatter = new HelpFormatter();
    	formatter.printHelp( "epreuveloader", options );
    	System.exit(1);
    }
    //traitement
    ExportCoeff eco = new ExportCoeff("../samples/export/regle.csv");
    DBManager.URI= dburi;
    DBManager.USER = dbuser;
    DBManager.PASSWORD = dbpwd;
    CSVPrinter pr = null;
    try {
		pr = eco.buildCVSPrinter();
		eco.writeDB(pr,nameSerie,nameMention,nameOption,nameEuro);
	} catch (IOException e) {
		LOG.severe(e.getMessage());
	}
    
}
 
开发者ID:HanBnrd,项目名称:projectBAC,代码行数:81,代码来源:Main.java

示例12: usage

import org.apache.commons.cli.HelpFormatter; //导入方法依赖的package包/类
public static void usage(String nameApp, String descriptionApp, Options options) {

		HelpFormatter formatter = new HelpFormatter();
		formatter.printHelp(nameApp, descriptionApp, options, "");
		System.exit(1);
	}
 
开发者ID:pfratta,项目名称:ParquetUtils,代码行数:7,代码来源:CLUtils.java

示例13: printUsage

import org.apache.commons.cli.HelpFormatter; //导入方法依赖的package包/类
private static void printUsage() {
	HelpFormatter formatter = new HelpFormatter();
	formatter.printHelp("java -jar cuttlefish.jar [options]", options);
}
 
开发者ID:dev-cuttlefish,项目名称:cuttlefish,代码行数:5,代码来源:Cuttlefish.java

示例14: parseInput

import org.apache.commons.cli.HelpFormatter; //导入方法依赖的package包/类
private static boolean parseInput(String[] args) {
	String[] validFunctions = { "verify", "sign" };
	Options options = createCLI();		
	
	CommandLineParser parser = new DefaultParser();
        HelpFormatter formatter = new HelpFormatter();
        CommandLine cmd;

        try {
            cmd = parser.parse(options, args);
        } catch (ParseException e) {
            System.out.println(e.getMessage());
            formatter.printHelp("utility-name", options);
            return false;
        }

        if (!Arrays.stream(validFunctions).parallel().anyMatch(cmd.getOptionValue("function")::contains)) {
        	return false;
        }
        
        function = cmd.getOptionValue("function");
        
        String input = cmd.getOptionValue("input");
        String key = cmd.getOptionValue("key");
        if(cmd.hasOption("file")) {
            file = true;
        }
       	        
        if(function.contains("verify")){
        	if(file){
        		signature = readSignatureFromFile(input);
        	}
        	else {
	        	signature = Base64.decode(input.getBytes());
	        }
        	publicKeyFilename = key;
        }
        
        else if (function.contains("sign")) {
			message = input.getBytes();
			privateKeyFilename = key;			
		}
        
        return true;
}
 
开发者ID:true-gler,项目名称:ISO9796SignerVerifier,代码行数:46,代码来源:App.java

示例15: printHelp

import org.apache.commons.cli.HelpFormatter; //导入方法依赖的package包/类
private static void printHelp() {
    HelpFormatter formatter = new HelpFormatter();
    formatter.printHelp("tabula", BANNER, buildOptions(), "", true);
}
 
开发者ID:redmyers,项目名称:484_P7_1-Java,代码行数:5,代码来源:CommandLineApp.java


注:本文中的org.apache.commons.cli.HelpFormatter.printHelp方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。