An annotation based command line parser

JCommander star1000+

This is an annotation based parameter parsing framework for Java 8.

The full doc is available at http://jcommander.org.

Java port of Python‘s famous argparse command-line argument parser. https://argparse4j.github.io/

Argparse4j is a command line argument parser library for Java based on Python‘s argparse module.

Argparse4j is available in Maven central repository:

<dependency>
  <groupId>net.sourceforge.argparse4j</groupId>
  <artifactId>argparse4j</artifactId>
  <version>0.8.0</version>
</dependency>

https://github.com/argparse4j/argparse4j

https://github.com/jankroken/commandline

The Apache Commons CLI library provides an API for parsing command line options passed to programs. It‘s also able to print help messages detailing the options available for a command line tool.

Commons CLI supports different types of options:

http://commons.apache.org/proper/commons-cli/

https://stackoverflow.com/questions/11704338/java-cli-commandlineparser

https://github.com/jatoben/CommandLine

Mirror of Apache Commons CLI

https://github.com/apache/commons-cli

CLI Parser is a tiny (10k jar), super easy to use library for parsing various kinds of command line arguments or property lists. Using annotations on your fields or JavaBean properties you can specify what configuration is available. Here is an example:

public class Loader {

  @Argument
  private static Boolean hdfs = false;

  @Argument(alias = "r", description = "Regular expression to parse lines", required = true)
  private static String regex;

  @Argument(alias = "k", description = "Key column", required = true)
  private static String key;

  @Argument(alias = "p", description = "Key prefix")
  private static String prefix;

  @Argument(alias = "c", description = "Column groups", delimiter = ",")
  private static String[] columns;

  @Argument(alias = "n", description = "Column names", delimiter = ",")
  private static String[] names;

  @Argument(alias = "h", description = "Redis host")
  private static String host = "localhost";

  @Argument(alias = "p", description = "Redis port")
  private static Integer port = 6379;

  public static void main(String[] args) throws IOException {
    // unparsed will contain all unparsed arguments to the command line
    List<String> unparsed = Args.parseOrExit(Loader.class, args);
    // Loader‘s fields will be populated after this line or the program will exit with usage
  }
}

In this case we are configuring static fields, but you can also use the same system with instances. If you pass in a wrong command line argument you will get the usage message:

Usage: com.sampullara.cli.Example
  -hdfs [flag]
  -regex (-r) [String] Regular expression to parse lines
  -key (-k) [String] Key column
  -prefix (-p) [String] Key prefix
  -columns (-c) [String[,]] Column groups
  -names (-n) [String[,]] Column names
  -host (-h) [String] Redis host (localhost)
  -port (-p) [Integer] Redis port (6379)

That message will print out the names and aliases of the arguments, type, description and a default value for the parameter if there is one. You can add it to your code with:

<dependency>
  <groupId>com.github.spullara.cli-parser</groupId>
  <artifactId>cli-parser</artifactId>
  <version>1.1</version>
</dependency>

https://github.com/spullara/cli-parser

KeyStore Explorer is a free GUI replacement for the Java command-line utilities keytool and jarsigner.

Official website: http://keystore-explorer.org/

Features:

  • Create, load, save and convert between various KeyStore types: JKS, JCEKS, PKCS#12, BKS (V1 and V2) and UBER
  • Change KeyStore and KeyStore entry passwords
  • Delete or rename KeyStore entries
  • Cut/copy/paste KeyStore entries
  • Append certificates to key pair certificate chains
  • Generate RSA, ECC and DSA key pairs with self-signed X.509 certificates
  • Apply X.509 certificate extensions to generated key pairs and Certificate Signing Requests (CSRs)
  • View X.509 Certificate, CRL and CRL entry X.509 V3 extensions
  • Import and export keys and certificates in many formats: PKCS#12, PKCS#8, PKCS#7, DER/PEM X.509 certificate files, Microsoft PVK, SPC, PKI Path, OpenSSL
  • Generate, view and sign CSRs in PKCS #10 and SPKAC formats
  • Sign JAR files
  • Configure a CA Certs KeyStore for use with KeyStore operations

https://github.com/kaikramer/keystore-explorer

Library Usage:

  1. Drop the jar into your lib folder and add to build path.
  2. Choose the converter of your choice, they are named DocToPDFConverter, DocxToPDFConverter, PptToPDFConverter, PptxToPDFConverter and OdtToPDFConverter.
  3. Instantiate with 4 parameters
    • InputStream inStream: Document source stream to be converted
    • OutputStream outStream: Document output stream
    • boolean showMessages: Whether to show intermediate processing messages to Standard Out (stdout)
    • boolean closeStreamsWhenComplete: Whether to close input and output streams when complete
  4. Call the "convert()" method and wait.

Caveats and technical details:

This tool relies on Apache POI, xdocreport, docx4j and odfdom libraries. They are not 100% reliable and the output format may not always be what you desire.

DOC:

Generally ok but takes some time to convert.. I notice that after conversion, the paragraph spacing tends to increase affecting your page layout. Conversion is done using docx4j to convert DOC to DOCX then to PDF.(Cannot use xdocreport once the DOCX data is obtained as the intermediate data structure is docx4j specific.)

DOCX:

Very good results. Fast conversion too. Conversion is done using xdocreport library as it seems faster and more accurate than docx4j.

PPT and PPTX:

Resulting file is a PDF comprising of a PNG embedded in each page. Should be good enough for printing. This is the limitation of the Apache POI and docx4j libraries.

ODT:

Quality and speed as good as DOCX. Conversion is done using odfdom of the Apache ODF Toolkit.

Main Libraries

Apache POI: https://poi.apache.org/
xdocreport: http://code.google.com/p/xdocreport/
docx4j: http://www.docx4java.org/
odfdom: https://incubator.apache.org/odftoolkit/odfdom/

https://github.com/yeokm1/docs-to-pdf-converter

Pdf2Dom is a PDF parser that converts the documents to a HTML DOM representation. The obtained DOM tree may be then serialized to a HTML file or further processed. A command-line utility for converting the PDF documents to HTML is included in the distribution package. Pdf2Dom may be also used as an independent Java library with a standard DOM i…http://cssbox.sourceforge.net/pdf2dom/

Pdf2Dom is based on the Apache PDFBox™ library.

https://github.com/radkovo/Pdf2Dom

About

Generate scaffold with spring boot.

Generate CRUD basic with spring boot.

Scaffold for java web, a clean generate with simple classes.

https://github.com/NetoDevel/cli-spring-boot-scaffold

原文地址:https://www.cnblogs.com/softidea/p/8993281.html

时间: 2024-08-27 13:07:18

An annotation based command line parser的相关文章

【转载】Data Science at the Command Line

Data Science at the Command Line Data Science at the Command Line is a new book written by Jeroen Janssens. This website contains information about the upcoming workshop in London, the webcast from August 20th, instructions on how to install the Data

Command Line Skills

Part 1: Command Line Interface(CLI) The Command Line Interface (CLI), is a text-based interface to the computer, where the user types in a command and the computer then executes it. The CLI environment is provided by an application on the computer kn

logoff remote desktop sessions via command line tools

This trick I learned from my one of ex-college.  In Windows servers, only two remote desktop sessions allowed with administrative access. There are situations, you can't connect to the server via remote desktop because of two sessions already active.

Building QT projects from the command line

/************************************************************************ * Building QT projects from the command line * 说明: * 很多时候都是通过Qtcreator进行项目的创建以及编译,但是有时候可能 * 会遇到一些编译小问题,这时候命令行创建工程.编译工程可以作为测试.验证 * 的一种手段. * * 2016-3-2 深圳 南山平山村 曾剑锋 *************

MAC OS 如何安装命令行工具:Command Line Tools

打开终端输入:xcode-select --install 回车 安装好了测试结果:gcc -v 显示如下: xcode-select: note: install requested for command line developer tools apple-1tekiiMac:~ apple-1$ gcc -v Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-includ

msiexec command line arguments

Documented command line arguments Type MSIEXEC /? and you'll get the following on-screen help: Windows ® Installer. V 5.0.7601.17514 msiexec /Option <Required Parameter> [Optional Parameter] Install Options </package | /i> <Product.msi>

Can&#39;t use Subversion command line client: svn

使用Intellij IDEA的svn时提示出错:Can't use Subversion command line client: svn. 当我在使用svn,Checkout一个项目后,然后将其导入到Intellij idea中,出现这样的报错!经过google后,发现了问题,我的问题是:我安装的TortoiseSVN工具,本身是带有command-line功能的(我没有安装)如图: 所以报这个错误.如果安装的TortoiseSVN工具,本身是不带有command-line功能的,必须要安装

解决MySQL5.6 Warning: Using a password on the command line interface can be insecure

MySQL5.6在使用名文的密码登陆时,会出现:Warning: Using a password on the command line interface can be insecure 当然这样对于平常的登陆会无所谓,如果在脚本里使用使用的话,就会有问题: 解决这种问题的方法是需要在my.cnf中配置即可: 在my.cnf中加入如下配置 [mysqladump] user=my_name password=my_pass 重启MySQL 即可 以后再使用mysqldump命令就不需要加上任

How to build .apk file from command line(转)

How to build .apk file from command line Created on Wednesday, 29 June 2011 14:32 If you don’t want to install a number of programs for building your Android project, this article is for you. You will need only JDK, the Android SDK platform tools and