Java port of Python's famous argparse command-line argument parser.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
extensions
main
.classpath
.gitignore
.project Included superclasses containing annotations. Jul 3, 2012
.travis.yml
LICENSE.txt Update copyright year Aug 2, 2017
NEWS Updated links. Jun 2, 2018
README.rst
pom.xml Revert "Added test cases for #110." Mar 7, 2018
sphinx-make-html Use Sphinx as documentation tool Feb 18, 2013
wfarange.py Fix a couple of minor language issues Aug 4, 2017

README.rst

Argparse4j - The Java command-line argument parser library

https://travis-ci.org/argparse4j/argparse4j.svg?branch=master

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>

IMPORTANT: When upgrading from 0.4.4 or earlier version, read Migration. There is an important change in 0.5.0 which might break you code. The documentation describes the change and how to migrate from earlier versions.

There are still missing features which exist in argparse but not in argparse4j, but there are also new features which only exist in argparse4j.

Here is summary of features:

  • Supported positional arguments and named arguments.

  • Variable number of arguments.

  • Generates well formatted line-wrapped help message.

  • Suggests named arguments/sub-command if unrecognized arguments/sub-command were given, e.g.:

    unrecognized argument '--tpye'
    Did you mean:
      --type
  • Takes into account East Asian Width ambiguous characters when line-wrap.

  • Sub-commands like, git add.

  • Sub-command alias names, e.g., co for checkout.

  • Customizable option prefix characters, e.g. +f and /h.

  • Print default values in help message.

  • Choice from given collection of values.

  • Type conversion from option strings.

  • Can directly assign values into user defined classes using annotation.

  • Group arguments so that it will be printed in help message in more readable way.

  • Mutually exclusive argument group.

  • Read additional arguments from file.

  • Argument/sub-command abbreviations.

The primary documentation is done using Sphinx. You need Sphinx to run mvn site.

Upgrading to 0.5.0 or later versions

Please consult the documentation section for Migration.