Welcome!
- What is CLAME?
CLAME is an acronym for Command-Line Arguments Made Easy. You can use it to
easily process you Java aplications command-line arguments.
- Why CLAME?
Well, because I noticed that no one got so bored at the point of doing such
thing! Oh, and because I consider it usefull.
- How can I use CLAME?
At the command-line, it closely behaves as described in the POSIX convention
(read the requisites for more details). In terms of code, it's really simple:
just add the main JAR to your application CLASSPATH and read the API!
Here's an example:
import java.util.Vector;
import net.sourceforge.clame.CLAME;
import net.sourceforge.clame.CLAMEException;
public class MyApp
{
public static void main(String[] args)
{
CLAME clame=null;
try {
clame=new CLAME(args);
} catch (CLAMEException clamee) {
System.err.println("CLAMEException: "+clamee.getMessage());
System.exit(1);
}
if (clame.existsOption("help"))
System.out.println("This is help!");
String host=clame.getOption("host");
String port=clame.getOption("port");
if ((host!=null) && (port!=null))
System.out.println(host+":"+port);
Vector files=clame.getMultipleOption("files");
if (files!=null)
for (int i=0; i<files.size(); i++)
System.out.println((String)files.get(i));
System.exit(0);
}
}
Some results for this example:
"MyApp -help" would display "This is help!"
"MyApp -host 192.168.0.1 -port 1099" would display "192.168.0.1:1099"
"MyApp -files foo1.txt foo2.txt foo3.txt" would display:
foo1.txt
foo2.txt
foo2.txt
You should also take a look at the test program located in the source
package (TestCLAME.java).
- What about CLAMEs license?
It's GPL, so you can use it, hack it, and distribute it at your will. Read
license.txt for more details. And don't forget to give credit!
|