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


Java ParserProperties类代码示例

本文整理汇总了Java中org.kohsuke.args4j.ParserProperties的典型用法代码示例。如果您正苦于以下问题:Java ParserProperties类的具体用法?Java ParserProperties怎么用?Java ParserProperties使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: printUsage

import org.kohsuke.args4j.ParserProperties; //导入依赖的package包/类
private void printUsage(PrintWriter writer) {
    // fix defaults for options like help and other 0-arg booleans
    OptionHandlerRegistry.getRegistry().registerHandler(Boolean.class, BooleanNoDefOptionHandler.class);
    OptionHandlerRegistry.getRegistry().registerHandler(boolean.class, BooleanNoDefOptionHandler.class);

    ParserProperties prop = ParserProperties.defaults()
            .withUsageWidth(80)
            .withOptionSorter(null);

    ByteArrayOutputStream buf = new ByteArrayOutputStream();

    // new args instance to get correct defaults
    new CmdLineParser(new CliArgs(), prop)
    .printUsage(new OutputStreamWriter(buf, StandardCharsets.UTF_8), null);

    writer.println(MessageFormat.format(Messages.UsageHelp.replace("${tab}", "\t"),
            new String(buf.toByteArray(), StandardCharsets.UTF_8),
            DangerStatementOptionHandler.getMetaVariable() + '\n' + DbObjTypeOptionHandler.getMetaVariable()));
}
 
开发者ID:pgcodekeeper,项目名称:pgcodekeeper,代码行数:20,代码来源:CliArgs.java

示例2: Exporter

import org.kohsuke.args4j.ParserProperties; //导入依赖的package包/类
public Exporter(String[] args) {
    final CmdLineParser parser = new CmdLineParser(this, ParserProperties.defaults().withUsageWidth(80));
    try {
        parser.parseArgument(args);
    } catch (CmdLineException e) {
        System.err.println(e.getMessage());
        print_usage_and_exit_(parser);
        /* UNREACHABLE */
    }

    // If help is requested, simply print that.
    if (help) {
        print_usage_and_exit_(parser);
        /* UNREACHABLE */
    }

    // If there are no files, comlain with a non-zero exit code.
    if (dir == null)
        System.exit(EX_USAGE);

    dirPath = FileSystems.getDefault().getPath(dir);
}
 
开发者ID:groupon,项目名称:monsoon,代码行数:23,代码来源:Exporter.java

示例3: ApiBin

import org.kohsuke.args4j.ParserProperties; //导入依赖的package包/类
public ApiBin(String[] args) {
    final CmdLineParser parser = new CmdLineParser(this, ParserProperties.defaults().withUsageWidth(80));
    try {
        parser.parseArgument(args);
    } catch (CmdLineException e) {
        System.err.println(e.getMessage());
        print_usage_and_exit_(parser);
        /* UNREACHABLE */
    }

    // If help is requested, simply print that.
    if (help) {
        print_usage_and_exit_(parser);
        /* UNREACHABLE */
    }
}
 
开发者ID:groupon,项目名称:monsoon,代码行数:17,代码来源:ApiBin.java

示例4: RhistMain

import org.kohsuke.args4j.ParserProperties; //导入依赖的package包/类
/**
 * Initialize the verifier, using command-line arguments.
 *
 * @param args The command-line arguments passed to the program.
 */
public RhistMain(String[] args) {
    final CmdLineParser parser = new CmdLineParser(this, ParserProperties.defaults().withUsageWidth(80));
    try {
        parser.parseArgument(args);
    } catch (CmdLineException e) {
        System.err.println(e.getMessage());
        print_usage_and_exit_(parser);
        /* UNREACHABLE */
    }

    // If help is requested, simply print that.
    if (help) {
        print_usage_and_exit_(parser);
        /* UNREACHABLE */
    }

    // If there are no files, comlain with a non-zero exit code.
    if (dir == null)
        System.exit(EX_USAGE);

    path_ = FileSystems.getDefault().getPath(dir);
}
 
开发者ID:groupon,项目名称:monsoon,代码行数:28,代码来源:RhistMain.java

示例5: Verify

import org.kohsuke.args4j.ParserProperties; //导入依赖的package包/类
/**
 * Initialize the verifier, using command-line arguments.
 * @param args The command-line arguments passed to the program.
 */
public Verify(String[] args) {
    final CmdLineParser parser = new CmdLineParser(this, ParserProperties.defaults().withUsageWidth(80));
    try {
        parser.parseArgument(args);
    } catch (CmdLineException e) {
        System.err.println(e.getMessage());
        print_usage_and_exit_(parser);
        /* UNREACHABLE */
    }

    // If help is requested, simply print that.
    if (help) {
        print_usage_and_exit_(parser);
        /* UNREACHABLE */
    }

    // If there are no files, comlain with a non-zero exit code.
    if (files.isEmpty())
        System.exit(EX_USAGE);
}
 
开发者ID:groupon,项目名称:monsoon,代码行数:25,代码来源:Verify.java

示例6: parseCommandLineArgumentsAndRun

import org.kohsuke.args4j.ParserProperties; //导入依赖的package包/类
private static void parseCommandLineArgumentsAndRun(String[] args) {
	CommandLineParameters parameters = new CommandLineParameters();
	AmidstMetaData metadata = createMetadata();
	CmdLineParser parser = new CmdLineParser(
			parameters,
			ParserProperties.defaults().withShowDefaults(false).withUsageWidth(120).withOptionSorter(null));
	try {
		parser.parseArgument(args);
		run(parameters, metadata, parser);
	} catch (CmdLineException e) {
		System.out.println(metadata.getVersion().createLongVersionString());
		System.err.println(e.getMessage());
		parser.printUsage(System.out);
		System.exit(2);
	}
}
 
开发者ID:toolbox4minecraft,项目名称:amidst,代码行数:17,代码来源:Amidst.java

示例7: doMain

import org.kohsuke.args4j.ParserProperties; //导入依赖的package包/类
private final void doMain(String... args) throws Exception {
    final ParserProperties properties = ParserProperties.defaults()
        .withUsageWidth(80)
        .withShowDefaults(true);
    final CmdLineParser parser = new CmdLineParser(this, properties);
    try {
        parser.parseArgument(args);
        final int enabledBoilers = (zlib_ ? 1:0) + (lzf_ ? 1:0) + (snappy_ ? 1:0);
        if (compress_ == null && decompress_ == null) {
            throw new IllegalArgumentException("Missing '--compress' or '--decompress' " +
                "argument.");
        } else if (compress_ != null && decompress_ != null) {
            throw new IllegalArgumentException("Must specify only one of '--compress' or " +
                "'--decompress' arguments.");
        } else if (enabledBoilers > 1) {
            throw new IllegalArgumentException("Can only specify one of --zlib, --lzf, or --snappy.");
        } else if (enabledBoilers == 0) {
            throw new IllegalArgumentException("Must specify at least one of --zlib, --lzf, or --snappy.");
        }
        run(); // Go!
    } catch (Exception e) {
        log.debug("Failed to start; see usage.", e);
        parser.printUsage(System.err);
    }
}
 
开发者ID:markkolich,项目名称:boildown,代码行数:26,代码来源:Boil.java

示例8: doMain

import org.kohsuke.args4j.ParserProperties; //导入依赖的package包/类
private void doMain(final String[] args) throws Exception {
    final ParserProperties properties = ParserProperties.defaults().withUsageWidth(80);
    final CmdLineParser parser = new CmdLineParser(this, properties);
    try {
        parser.parseArgument(args);
        if (_url == null) {
            throw new CmdLineException(parser, "URL to camera stream required.", null);
        }
        // http://1.0.0.6:8085/axis-cgi/jpg/image.cgi?resolution=640x480
        Camera axis = new Camera("Axis 2100 Network Camera", _url, "", "", Constants.REFRESH_RATE );

        CameraFrame frame = new CameraFrame( axis );
        frame.setVisible(true);
        frame.run();
    } catch (Exception e) {
        System.err.println("Usage:");
        parser.printUsage(System.err);
    }
}
 
开发者ID:markkolich,项目名称:axisviewer,代码行数:20,代码来源:AxisViewer.java

示例9: main

import org.kohsuke.args4j.ParserProperties; //导入依赖的package包/类
/**
 * @param args the command line arguments
 * @throws java.io.IOException the exception
 * @throws java.lang.InterruptedException the exception
 */
public static void main(String[] args) throws IOException, InterruptedException {
    try {
        Griffin griffin = new Griffin();

        CmdLineParser parser = new CmdLineParser(griffin, ParserProperties.defaults().withUsageWidth(120));
        parser.parseArgument(args);

        if (griffin.help || griffin.version || args.length == 0) {
            griffin.printHelpMessage();
            parser.printUsage(System.out);
        }
        else {
            griffin.commands.execute();
        }
    }
    catch (CmdLineException ex) {
        Logger.getLogger(Griffin.class.getName()).log(Level.SEVERE, null, ex);
    }
}
 
开发者ID:pawandubey,项目名称:griffin,代码行数:25,代码来源:Griffin.java

示例10: execute

import org.kohsuke.args4j.ParserProperties; //导入依赖的package包/类
/**
 * Executes the command
 */
@Override
public void execute() {
    Griffin griffin = new Griffin();
    if (help) {
        System.out.println("Preview the site on the given port: default: 9090");
        System.out.println("usage: griffin preview [option]");
        System.out.println("Options: " + LINE_SEPARATOR);
        CmdLineParser parser = new CmdLineParser(this, ParserProperties.defaults().withUsageWidth(120));
        parser.printUsage(System.out);
    }
    else {
        griffin.printAsciiGriffin();
        griffin.preview(port);
    }
}
 
开发者ID:pawandubey,项目名称:griffin,代码行数:19,代码来源:PreviewCommand.java

示例11: execute

import org.kohsuke.args4j.ParserProperties; //导入依赖的package包/类
/**
 * Executes the command
 */
@Override
public void execute() {
    if (help) {
        System.out.println("Publish the content in the current Griffin directory.");
        System.out.println("usage: griffin publish [option]");
        System.out.println("Options: " + LINE_SEPARATOR);
        CmdLineParser parser = new CmdLineParser(this, ParserProperties.defaults().withUsageWidth(120));
        parser.printUsage(System.out);
        return;
    }
    try {
        Griffin griffin = new Griffin();
        griffin.printAsciiGriffin();
        griffin.publish(fastParse, rebuild);
        System.out.println("All done for now! I will be bach!");
    }
    catch (IOException | InterruptedException ex) {
        Logger.getLogger(PublishCommand.class.getName()).log(Level.SEVERE, null, ex);
    }
}
 
开发者ID:pawandubey,项目名称:griffin,代码行数:24,代码来源:PublishCommand.java

示例12: execute

import org.kohsuke.args4j.ParserProperties; //导入依赖的package包/类
/**
 * Executes the command
 */
@Override
public void execute() {
    try {

        if (help || args.isEmpty()) {
            System.out.println("Scaffold out a new Griffin directory structure.");
            System.out.println("usage: griffin new [option] <path>");
            System.out.println("Options: " + LINE_SEPARATOR);
            CmdLineParser parser = new CmdLineParser(this, ParserProperties.defaults().withUsageWidth(120));
            parser.printUsage(System.out);
            return;
        }
        else {
            filePath = Paths.get(args.get(0));
        }
        Griffin griffin = new Griffin(filePath.resolve(name));
        griffin.initialize(filePath, name);
        System.out.println("Successfully created new site.");
    }
    catch (IOException | URISyntaxException ex) {
        Logger.getLogger(NewCommand.class.getName()).log(Level.SEVERE, null, ex);
    }
}
 
开发者ID:pawandubey,项目名称:griffin,代码行数:27,代码来源:NewCommand.java

示例13: parse

import org.kohsuke.args4j.ParserProperties; //导入依赖的package包/类
public static Options parse(final String[] args)
  throws IOException
{
  Options options = new Options();
  CmdLineParser parser = new CmdLineParser(options, ParserProperties.defaults().withUsageWidth(120));
  try {
    // parse the arguments.
    parser.parseArgument(args);

    if (options.arguments.isEmpty() || options.arguments.size() < 2 || options.showUsage) {
      usage(parser);
    }
  } catch (CmdLineException e) {
    System.err.println(e.getMessage());
    System.err.println();
    usage(parser);
  }
  
  return options;
}
 
开发者ID:goeckeler,项目名称:katas-sessions,代码行数:21,代码来源:Options.java

示例14: doMain

import org.kohsuke.args4j.ParserProperties; //导入依赖的package包/类
public void doMain(String[] args) {

		ParserProperties props = ParserProperties.defaults().withUsageWidth(80);
		CmdLineParser parser = new CmdLineParser(this, props);
		try {
			parser.parseArgument(args);
			if (help) {
				System.err.println(format("java {0} [OPTIONS] [CONFIG...]", Main.class.getName()));
				parser.printUsage(System.err);
				return;
			}
		} catch (CmdLineException ex) {
			System.err.println(format("java {0} [OPTIONS] [CONFIG...]", Main.class.getName()));
			parser.printUsage(System.err);
			return;
		}

		startServer();
	}
 
开发者ID:agwlvssainokuni,项目名称:springapp,代码行数:20,代码来源:Main.java

示例15: main

import org.kohsuke.args4j.ParserProperties; //导入依赖的package包/类
public static void main(String[] argv)
{
    Args args = new Args();
    CmdLineParser parser = new CmdLineParser(args,
            ParserProperties.defaults().withOptionSorter(null)
                .withUsageWidth(80).withShowDefaults(false));
    
    boolean wasExcept = false;
    try {
        parser.parseArgument(argv);
    }
    catch (CmdLineException e)
    {
        System.out.println(e.getMessage());
        wasExcept = true;
    }

    if (wasExcept || args.help)
    {
        
        System.out.println("java -jar prettygalaxy.v1.jar [options...]");
        parser.printUsage(System.out);
        
        System.exit(args.help?0:1);
    }
    
    args.sanitize();
    
    for (int i = 0; i < args.numRuns; i++)
    {
        generate(args);
        
        if (args.out == null)
            break;
    }
}
 
开发者ID:dattasid,项目名称:ProcGalaxy,代码行数:37,代码来源:SimpleGalaxyGfx.java


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