org.kohsuke.args4j.ParserProperties Java Examples
The following examples show how to use
org.kohsuke.args4j.ParserProperties.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Exporter.java From monsoon with BSD 3-Clause "New" or "Revised" License | 6 votes |
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); }
Example #2
Source File: AdditionalOptionsCmdLineParser.java From buck with Apache License 2.0 | 6 votes |
/** * Creates a new command line owner that parses arguments/options and set them into the given * object. * * @param bean instance of a class annotated by {@link Option}, {@link Argument} and {@link * AdditionalOptions}. This object will receive values. If this is null, the processing will * be skipped, which is useful if you'd like to feed metadata from other sources. * @throws IllegalAnnotationError if the option bean class is using args4j annotations * incorrectly. * @see CmdLineParser#CmdLineParser(Object) */ public AdditionalOptionsCmdLineParser(PluginManager pluginManager, Object bean) { /** * Disable '@' syntax. We convert this ourselves in {@link BuckArgsMethods#expandAtFiles}, so * options passed to parseArgument() should already be properly expanded. This allows us to have * things like `buck run @file //:script -- @this_goes_to_the_script`, as @file is expanded * before hitting this method. */ super(null, ParserProperties.defaults().withAtSyntax(false)); this.pluginManager = pluginManager; // This is copied in simplified form from CmdLineParser constructor and put here to save the // reference to the plugin manager before doing the parsing of options. new ClassParser().parse(bean, this); getOptions().sort(DEFAULT_COMPARATOR); Set<Class<?>> visited = new HashSet<>(); parseAnnotations(new ClassParser(), bean, visited); }
Example #3
Source File: NewCommand.java From griffin with Apache License 2.0 | 6 votes |
/** * 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); } }
Example #4
Source File: PublishCommand.java From griffin with Apache License 2.0 | 6 votes |
/** * 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); } }
Example #5
Source File: PreviewCommand.java From griffin with Apache License 2.0 | 6 votes |
/** * 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(); System.out.println("Starting preview on port " + port); griffin.preview(port); } }
Example #6
Source File: Griffin.java From griffin with Apache License 2.0 | 6 votes |
/** * @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); } }
Example #7
Source File: Amidst.java From amidst with GNU General Public License v3.0 | 6 votes |
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); } }
Example #8
Source File: Amidst.java From amidst with GNU General Public License v3.0 | 6 votes |
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); } }
Example #9
Source File: Verify.java From monsoon with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * 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); }
Example #10
Source File: RhistMain.java From monsoon with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * 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); }
Example #11
Source File: ApiBin.java From monsoon with BSD 3-Clause "New" or "Revised" License | 6 votes |
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 */ } }
Example #12
Source File: FileConvert.java From monsoon with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * 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); }
Example #13
Source File: FileConvert.java From monsoon with BSD 3-Clause "New" or "Revised" License | 5 votes |
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); }
Example #14
Source File: PartialCmdLineParser.java From jsonix-schema-compiler with BSD 2-Clause "Simplified" License | 4 votes |
public PartialCmdLineParser(Object bean, ParserProperties parserProperties) { super(bean, parserProperties); }
Example #15
Source File: Repl.java From es6draft with MIT License | 4 votes |
private static void parseOptions(Options options, String[] args) { ParserProperties properties = ParserProperties.defaults().withUsageWidth(128); CmdLineParser parser = new CmdLineParser(options, properties); try { parser.parseArgument(args); } catch (CmdLineException e) { System.err.println(e.getMessage()); System.err.println(getUsageString(parser, false)); System.exit(1); } if (options.showVersion) { System.out.println(getVersionString()); System.exit(0); } if (options.showHelp) { System.out.println(getUsageString(parser, false)); System.exit(0); } if (options.showExtendedHelp) { System.out.println(getUsageString(parser, true)); System.exit(0); } if (options.printCode || options.printCodeWithTypes || options.debugInfo) { // Disable interpreter when bytecode is requested options.noInterpreter = true; } if (options.fileName != null) { // Execute as last script if (options.fileName.toString().equals("-")) { // "-" is a short-hand to request reading from System.in if (System.console() == null) { // System.in is not interactive options.evalScripts.add(new EvalString(read(System.in))); } else { options.interactive = true; } } else { options.evalScripts.add(new EvalPath(options.fileName, EvalPath.Type.Script)); } } if (options.evalScripts.isEmpty()) { // Default to interactive mode when no files or expressions were set options.interactive = true; } }
Example #16
Source File: CmdLineResult.java From ethereum-secure-proxy with GNU Affero General Public License v3.0 | 4 votes |
void printExample() { CmdLineParser parser = new CmdLineParser(this, ParserProperties.defaults().withShowDefaults(false)); parser.printUsage(System.out); }
Example #17
Source File: CommandLineArguments.java From portmapper with GNU General Public License v3.0 | 4 votes |
public CommandLineArguments() { parser = new CmdLineParser(this, ParserProperties.defaults().withShowDefaults(true).withUsageWidth(80)); }