• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ParserProperties类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: FileConvert

import org.kohsuke.args4j.ParserProperties; //导入依赖的package包/类
public FileConvert(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 verbose mode is requested, dial up the log spam.
    if (verbose) {
        Logger.getLogger("com.groupon.lex").setLevel(Level.INFO);
        Logger.getLogger("com.github.groupon.monsoon").setLevel(Level.INFO);
    }

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

    srcdir_path_ = FileSystems.getDefault().getPath(srcdir);
}
 
开发者ID:groupon,项目名称:monsoon,代码行数:29,代码来源:FileConvert.java


示例17: FileConvert

import org.kohsuke.args4j.ParserProperties; //导入依赖的package包/类
/**
 * Initialize the verifier, using command-line arguments.
 *
 * @param args The command-line arguments passed to the program.
 */
public FileConvert(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 verbose mode is requested, dial up the log spam.
    if (verbose)
        Logger.getLogger("com.groupon.lex").setLevel(Level.INFO);

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

    srcdir_path_ = FileSystems.getDefault().getPath(srcdir);
    dstdir_path_ = FileSystems.getDefault().getPath(dstdir);
}
 
开发者ID:groupon,项目名称:monsoon,代码行数:33,代码来源:FileConvert.java


示例18: configure

import org.kohsuke.args4j.ParserProperties; //导入依赖的package包/类
private static ParserProperties configure() {
	CmdLineParser.registerHandler(BuiltIn.class, AltEnumOptionHandler.class);
	ParserProperties properties = ParserProperties.defaults();
	properties.withOptionSorter(null);
	properties.withUsageWidth(100);
	return properties;
}
 
开发者ID:nickman,项目名称:jmxlocal,代码行数:8,代码来源:Command.java


示例19: parse

import org.kohsuke.args4j.ParserProperties; //导入依赖的package包/类
/**
 * Parses and checks the program arguments. If the arguments are invalid or the user requested
 * the help message, this method returns <code>false</code> and writes the message for the user.
 * If the parsing is successful, this method does not print anything to the output.
 * 
 * @param args
 *            the arguments to parse
 * @return <code>true</code> if the arguments were successfully parsed, <code>false</code> if
 *         arguments are invalid or the user requested the help message (<code>false</code>
 *         generally means that SETTE should stop)
 */
public boolean parse(@NonNull String... args) {
    // register handler for tool and set the current configuration for it
    OptionHandlerRegistry.getRegistry().registerHandler(SetteToolConfiguration.class,
            ToolOptionHandler.class);
    ToolOptionHandler.configuration = configuration;

    // parse args with preset properties
    ParserProperties parserProps = ParserProperties.defaults()
            .withShowDefaults(true)
            .withUsageWidth(80);
    CmdLineParser parser = new CmdLineParser(this, parserProps);

    try {
        parser.parseArgument(args);

        if (help) {
            printHelp(parser);
            return false;
        } else {
            return true;
        }
    } catch (CmdLineException ex) {
        errorOutput.println(ex.getMessage());
        printHelp(parser);
        return false;
    }
}
 
开发者ID:SETTE-Testing,项目名称:sette-tool,代码行数:39,代码来源:ArgumentParser.java


示例20: getParser

import org.kohsuke.args4j.ParserProperties; //导入依赖的package包/类
private CmdLineParser getParser() {
  if (parser == null) {
    final ParserProperties properties = ParserProperties.defaults();
    properties.withUsageWidth(80);

    parser = new CmdLineParser(this, properties);
  }

  return parser;
}
 
开发者ID:jingweno,项目名称:gaffer,代码行数:11,代码来源:Gaffer.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Field类代码示例发布时间:2022-05-21
下一篇:
Java Rect类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap