|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.toronto.cs.util.Clapi.OptSpec
public static class Clapi.OptSpec
An option specifier provides a builder API for specifying the features of an option.
Constructor Summary | |
---|---|
Clapi.OptSpec(Clapi.OptParser _parser)
|
Method Summary | |
---|---|
Clapi.OptSpec |
argumentArity(int v)
Specifies the number of arguments this parameter should receive. |
Clapi.BooleanOpt |
asBoolean()
Wraps this specification as a Boolean option, adds it to the parser, and returns the Boolean option. |
Clapi.FileNameOpt |
asFileName()
Wraps this specification as a FileName option, adds it to the parser, and returns the FileName option. |
Clapi.HelpOpt |
asHelp()
Wraps this specification as a Help option, adds it to the parser, and returns the Help option. |
Clapi.IntOpt |
asInt()
Wraps this specification as a Int option, adds it to the parser, and returns the Int option. |
Clapi.StringOpt |
asString()
Wraps this specification as a String option, adds it to the parser, and returns the String option. |
Clapi.OptSpec |
description(java.lang.String v)
Specifies this option's description: used in usage information. |
Clapi.OptSpec |
equals(java.lang.String v)
Adds a equals specifier to this option spec. |
int |
getArgumentArity()
|
java.lang.String |
getDescription()
|
java.util.List |
getEqualses()
|
java.util.List |
getGroups()
Return the list of groups this option is a member of. |
java.util.List |
getLongNames()
|
int |
getMaxArity()
|
int |
getMinArity()
|
boolean |
getNameless()
|
java.util.List |
getPrefixes()
|
boolean |
getRequired()
|
java.util.List |
getShortNames()
|
java.util.List |
getSuffixes()
|
Clapi.OptSpec |
group(java.lang.String groupName)
Specifies this option's string group name. |
boolean |
isList()
Return true if this option may be specified more than once. |
boolean |
isRequired()
Return true if this option must be specified. |
Clapi.OptSpec |
list()
alias for maxArity (-1) |
Clapi.OptSpec |
longName(java.lang.String v)
Adds a long name to this option spec. |
Clapi.OptSpec |
maxArity(int v)
Specifies this option's maximum arity. |
Clapi.OptSpec |
minArity(int v)
Specifies this option's minimum arity. |
Clapi.OptSpec |
nameless()
Specifies that this option will be nameless. |
Clapi.OptSpec |
optional()
alias for minArity (0) |
Clapi.OptSpec |
prefix(java.lang.String v)
Adds a prefix specifier to this option spec. |
Clapi.OptSpec |
required()
alias for minArity (1) |
Clapi.OptSpec |
shortName(char v)
Adds a short name to this option spec. |
Clapi.OptSpec |
suffix(java.lang.String v)
Adds a suffix specifier to this option spec. |
Clapi.OptSpec |
terminal()
Specifies that this option should end the parsing of the tokens, and swallow all remaining tokens whole as its option value list. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Clapi.OptSpec(Clapi.OptParser _parser)
Method Detail |
---|
public Clapi.HelpOpt asHelp()
public Clapi.BooleanOpt asBoolean()
public Clapi.StringOpt asString()
public Clapi.IntOpt asInt()
public Clapi.FileNameOpt asFileName()
public Clapi.OptSpec longName(java.lang.String v)
public Clapi.OptSpec shortName(char v)
public Clapi.OptSpec equals(java.lang.String v)
Adds a equals specifier to this option spec.
An equals specifier says that if a particular string is found on the command line, it is to be processed by a particular option.
public Clapi.OptSpec prefix(java.lang.String v)
Adds a prefix specifier to this option spec.
An prefix specifier says that if a string with a particular prefix is found on the command line, it is to be processed by a particular option.
public Clapi.OptSpec suffix(java.lang.String v)
Adds a suffix specifier to this option spec.
An suffix specifier says that if a string with a particular suffix is found on the command line, it is to be processed by a particular option.
public Clapi.OptSpec nameless()
Specifies that this option will be nameless.
There may only be one nameless option. If an option is encountered which has no name (no short name or long name), and does not match any of the suffix, prefix, or equals rules), then it is processed by the nameless option, if it is available. Nameless options are often used for utilities which process a number of filenames, which may be arbitrary strings.
public Clapi.OptSpec terminal()
Specifies that this option should end the parsing of the tokens, and swallow all remaining tokens whole as its option value list.
public Clapi.OptSpec minArity(int v)
Specifies this option's minimum arity. It is a parse error
for the option opt
to be specified fewer than
opt.getMinArity()
times.
Some min arities of note are 0 (which means that the option is optional), and 1 (which means that the option is required).
The default minArity of any option is 0, meaning that it is optional.
required
,
optional()
public Clapi.OptSpec maxArity(int v)
Specifies this option's maximum arity. It is a parse error
for the option opt
to be specified more than
opt.getMaxArity()
times.
There is also special handling for values less than 0. If the maximuum arity is -1 or lower, then the option may be specified as many times as the user likes, and there will be no error.
Some min arities of note are 0 (which means that the option cannot be specified -- this is a stupid thing to set max arity to), 1 (which means that the option can only be specified once -- it is a singleton), and -1 (which means that the option can be specified as many times as the user would like.)
The default maxArity of any option is 1, meaning that it cannot be specified more than once.
list()
public Clapi.OptSpec argumentArity(int v)
Specifies the number of arguments this parameter should receive.
If 0 arguments are specified,
public Clapi.OptSpec description(java.lang.String v)
public Clapi.OptSpec group(java.lang.String groupName)
public Clapi.OptSpec optional()
public Clapi.OptSpec required()
public Clapi.OptSpec list()
public java.util.List getLongNames()
public java.util.List getShortNames()
public java.util.List getEqualses()
public java.util.List getPrefixes()
public java.util.List getSuffixes()
public boolean getNameless()
public java.lang.String getDescription()
public boolean getRequired()
public int getMinArity()
public int getMaxArity()
public int getArgumentArity()
public boolean isRequired()
public boolean isList()
public java.util.List getGroups()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |