Args Parser

Copyright (C) 1997-2004 by Haruaki TAMADA All rights reserved.
Last Modified: Mon Jan 10 11:07:28 JST 2005

[ Japanese | English ]

Contents

Go to top of page

Abstract

This library is parser of command line option.

Go to top of page

Features

API Document [No Frames]

Sorry, api document is only Japanese.

Go to top of page

license

License is GNU GPL(GNU General Public License).

GNU General Public License

link about GPL

from GPL FAQ.

Q. In an object-oriented language such as Java, if I use a class that is GPL'ed without modifying, and subclass it, in what way does the GPL affect the larger program?

A. Subclassing is creating a derivative work. Therefore, the terms of the GPL affect the whole program where you create a subclass of a GPL'ed class.

Go to top of page

Download

ArgsParser-1.0.0.tar.gz
md5sum: ef6fd9fa1d4ec1921ba9745191ad8ed0
ArgsParser-1.0.1.tar.gz
md5sum: b3a2735231c50535e1c9c9748512201c

ChangeLog

Go to top of page

Requires

Java 2 SDK 1.3 or higher

Apache Ant
Require. Use on build.
Jakarta Velocity
Optional. Use on create this document. For more detail see anakia
JUnit
Optional. Use unit testing.

Go to top of page

Install

Download ArgsParser-x.x.x.tar.gz and extract tarball.

$ gzip -cd ArgsParser-x.x.x.tar.gz | tar xvf -

use ArgsParser-x.x.x/lib/ArgsParser.jar archive.

Go to top of page

How to use

Option[] options = new Option[] {
    //           long option     argument type          short   description
    new Option("long-option1", "1", Option.REQUIRED_ARGUMENT, "description1"), 
    new Option("long-option2", "2", Option.OPTIONAL_ARGUMENT, "description2"), 
    new Option("long-option3", "3", Option.NO_ARGUMENT,       "description3"), 
};
Args arg = new Args(args, options);
Option[] parsedOptions = arg.getOptions();
for(int i = 0; i < parsedOptions.length; i++){
    System.out.println("arg" + i + ": " + parsedOptions[i]);
}

Above program execute result is follow.

$ java Prog --long-option1=value1 --long-otion2=value2 --long-option2 -3 hoge
arg1:    -1, --long-option1: value1[REQUIRE ARGUMENT]
arg2:    -2, --long-option2: value2[OPTIONAL_ARGUMENT]
arg3:    -2, --long-option2: [OPTIONAL_ARGUMENT]
arg4:    -3, --long-option3: [NO_ARGUMENT]

Go to top of page