Menu

Compiling

Chris DeGreef

It is very important to understand [how to interact with Argument], especially when setting up your own application to use it. Please be sure you have read that page before proceeding. since the same syntax is used to specify the parser behavior in your application.

The java code to define an Argument parser in your application is this.

ICmdLine argument = new CmdLine("argument1", "argument2" ...);

The parameter to the CmdLine constructor is a String[] where each element in the array is the definition of a single argument. Of course, "argument1" and "argument2" are just placeholders in this example. If we wanted a single boolean argument named --debug then it might look like this.

ICmdLine argument = new CmdLine("-t boolean -k debug");

And if we needed a port command as well we would just add that too.

ICmdLine argument = new CmdLine(
                     "-t boolean -k debug", 
                     "-t integer -k port");

We can continue to add more commands to Argument by just extending this array.

Defining the Parser - Argument definitions

Each argument is defined with a set of parameters. You must have at least one argument defined. But there is no maximum number of arguments for a single parser. The most important of the parameters is Type and Key. The other parameters modify the default behavior for the argument.

Argument Example
[Types] (--type)
[Naming the arguments] (--key)
[Multiple value Arguments] (--multiple)
[Required] argument (--required)
[Case sensitive values] (--casesensitive)
[Default values] (--default)
[Constraining to a range] (--range)
[Constraining to a regular expression] (--matches)
[Constraining to a list of values] (--list)
[Constraining to an enum class] (--enumList)
[Help message] (--help)

Advanced Topics

Argument Example
[Positional] (unnamed) arguments
Including [specification files] (@filename)
[Embedded Parsers] (--begin --end)

Related

Wiki: Case sensitive values
Wiki: Constraining to a list of values
Wiki: Constraining to a range
Wiki: Constraining to a regular expression
Wiki: Constraining to an enum class
Wiki: Default values
Wiki: Embedded Parsers
Wiki: Help message
Wiki: Home
Wiki: Multiple value Arguments
Wiki: Naming the arguments
Wiki: Positional
Wiki: Required
Wiki: Types
Wiki: how to interact with Argument
Wiki: specification files

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.