net.sf.mmm.util.cli.api
Annotation Type CliArgument


@Retention(value=RUNTIME)
@Documented
@Target(value={FIELD,METHOD})
public @interface CliArgument

A CliArgument is used to annotate a property (member variable of some class or setter-method) that should be set from a main-program via a commandline argument. Unlike CliOption a CliArgument is NOT triggered by its name but is identified by its position. The first commandline parameter that is no option or occurs after the argument "--" is treated as the first argument and further parameters can also only be arguments. Additionally the last CliArgument -property can have the type List if a proper generic is used to declare the item-type.
E.g. a program Foo may have one argument of type List<File> and you invoke Foo file1 file2 file3 then the property is set to a List equivalent to {new File("file1"), new File("file2"), new File("file3")}.
ATTENTION:
Whenever possible prefer a CliOption over a CliArgument. However having a single CliArgument is just fine. But having multiple arguments together in some mode can cause maintenance trouble. This is only supported to avoid limitations (e.g. if you want to implement something like "grep pattern [file]+") but NOT recommended.

Since:
2.0.0
Author:
Joerg Hohwiller (hohwille at users.sourceforge.net)

Required Element Summary
 String name
          The name of the argument used for help usage output.
 String usage
          The description of this argument for help usage.
 
Optional Element Summary
 boolean addAfter
          Determines if this CliArgument should be add after ( true) or before (false) the argument identified by addCloseTo().
 String addCloseTo
          The name of the argument where to add this CliArgument in the list of arguments.
 CliContainerStyle containerStyle
          The style of this argument if it has a container type.
 String id
          The ID of the argument used to identify the argument e.g. via addCloseTo().
 String mode
          The mode of this argument.
 boolean required
          The flag that indicates if this argument is required.
 

Element Detail

name

public abstract String name
The name of the argument used for help usage output.


usage

public abstract String usage
The description of this argument for help usage. It should be an internationalized message that will be localized using NlsMessage. NLS-arguments are "default" for the default value.

id

public abstract String id
The ID of the argument used to identify the argument e.g. via addCloseTo(). The default is the empty string that is treated as if the ID is set to the same value as name().

Default:
""

addAfter

public abstract boolean addAfter
Determines if this CliArgument should be add after ( true) or before (false) the argument identified by addCloseTo().

Default:
true

addCloseTo

public abstract String addCloseTo
The name of the argument where to add this CliArgument in the list of arguments. The default is ID_LAST.

See Also:
ID_FIRST, ID_LAST
Default:
"#last"

mode

public abstract String mode
The mode of this argument.

See Also:
CliOption.mode()
Default:
"default"

required

public abstract boolean required
The flag that indicates if this argument is required. The default value is true. Use a value of false to make this argument optional within it's mode.
ATTENTION:
Avoid optional arguments and use options instead. If you use optional arguments anyway, please note that potentially following options also need to be optional then.

See Also:
CliMode.parentIds()
Default:
true

containerStyle

public abstract CliContainerStyle containerStyle
The style of this argument if it has a container type. The default is CliContainerStyle.DEFAULT.

See Also:
CliStyle.containerStyle()
Default:
net.sf.mmm.util.cli.api.CliContainerStyle.DEFAULT


Copyright © 2001-2010 mmm-Team. All Rights Reserved.