Skip to content

wnebyte/j-args

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

j-args

A flexible argument-parser library.

Table of Contents

Sample

1: How to declare and parse arguments

The code below creates two arguments using the ArgumentFactory class; one required argument of type int, and one optional argument of type string.

ArgumentFactory factory = new ArgumentFactory();
factory.create("-foo, --foo", "description", true,
        null, "FOO", null, int.class);
factory.create("-bar, --bar", null, false, 
        null, "BAR", "default value", String.class);
Set<Argument> arguments = factory.getAll();

The below snippet demonstrates how to parse arguments and retrieve their values.

ArgsParser parser = new ArgsParser(arguments);
Args args = parser.parse("-bar 'this is a string' -foo 55");
int foo = args.get("-foo", int.class);
String bar = args.get("-bar", String.class);
// do something with your initialized arguments

See: www.github.com/wnebyte/j-arguments for additional documentation on how to use the ArgumentFactory class.

About

Flexible argument-parser library.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages