Skip to content

radarsh/args

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

args

A reusable solution for Command Line Arguments Parsing in Java

Usage

// Initiate the arguments engine.
ArgsEngine engine = new ArgsEngine();

// Configure the switches/options. Use true for valued options.
engine.add("-q", "--quiet");
engine.add("-o", "--redirect-output", true);
engine.add("-h", "--help");

// Perform the parsing. The 'args' is the String[] received by main method.
engine.parse(args);

// Start fetching states of switches.
boolean quiet = engine.getBoolean("-q");

if(engine.getBoolean("-o")) {
    // For valued options, use getString.
    String redir = engine.getString("-o");
}

// Use getNonOptions to filter out all options.
String[] nonOptions = engine.getNonOptions();

Releases

No releases published

Packages

No packages published

Languages