Class Options
- java.lang.Object
-
- com.aspectran.shell.command.option.Options
-
- All Implemented Interfaces:
java.io.Serializable
public class Options extends java.lang.Object implements java.io.Serializable
Main entry-point into the library.Options represents a collection of
Option
objects, which describe the possible options for a command-line.It may flexibly parse long and short options, with or without values. Additionally, it may parse only a portion of a commandline, allowing for flexible multi-stage parsing.
- See Also:
ParsedOptions
, Serialized Form
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Options
addOption(Option opt)
Adds an option instance.Options
addOptionGroup(OptionGroup group)
Add the specified option group.java.util.Collection<Option>
getAllOptions()
Retrieve a read-only list of options in this set.java.util.List<Option>
getHelpOptions()
Returns the Options for use by the HelpFormatter.java.util.List<java.lang.String>
getMatchingOptions(java.lang.String name)
Returns the options with a long name starting with the name specified.Option
getOption(java.lang.String name)
Retrieve theOption
matching the long or short name specified.OptionGroup
getOptionGroup(Option opt)
Returns the OptionGroup theopt
belongs to.java.util.List<java.lang.Object>
getRequiredOptions()
Returns the required options.java.lang.String
getTitle()
boolean
hasLongOption(java.lang.String name)
boolean
hasOption(java.lang.String name)
boolean
hasShortOption(java.lang.String name)
boolean
isEmpty()
Returnstrue
if no options have been added.boolean
isSkipParsingAtNonOption()
void
setSkipParsingAtNonOption(boolean skipParsingAtNonOption)
void
setTitle(java.lang.String title)
java.lang.String
toString()
Dump state, suitable for debugging.
-
-
-
Method Detail
-
getTitle
public java.lang.String getTitle()
-
setTitle
public void setTitle(java.lang.String title)
-
isSkipParsingAtNonOption
public boolean isSkipParsingAtNonOption()
-
setSkipParsingAtNonOption
public void setSkipParsingAtNonOption(boolean skipParsingAtNonOption)
-
addOptionGroup
public Options addOptionGroup(OptionGroup group)
Add the specified option group.- Parameters:
group
- the OptionGroup that is to be added- Returns:
- the resulting Options instance
-
addOption
public Options addOption(Option opt)
Adds an option instance.- Parameters:
opt
- the option that is to be added- Returns:
- the resulting Options instance
-
isEmpty
public boolean isEmpty()
Returnstrue
if no options have been added.- Returns:
true
if no options have been added
-
getAllOptions
public java.util.Collection<Option> getAllOptions()
Retrieve a read-only list of options in this set.- Returns:
- read-only Collection of
Option
objects in this descriptor
-
getHelpOptions
public java.util.List<Option> getHelpOptions()
Returns the Options for use by the HelpFormatter.- Returns:
- the List of Options
-
getRequiredOptions
public java.util.List<java.lang.Object> getRequiredOptions()
Returns the required options.- Returns:
- read-only List of required options
-
getOption
public Option getOption(java.lang.String name)
Retrieve theOption
matching the long or short name specified.The leading hyphens in the name are ignored (up to 2).
- Parameters:
name
- short or long name of theOption
- Returns:
- the option represented by name
-
getMatchingOptions
public java.util.List<java.lang.String> getMatchingOptions(java.lang.String name)
Returns the options with a long name starting with the name specified.- Parameters:
name
- the partial name of the option- Returns:
- the options matching the partial name specified, or an empty list if none matches
-
hasOption
public boolean hasOption(java.lang.String name)
-
hasLongOption
public boolean hasLongOption(java.lang.String name)
-
hasShortOption
public boolean hasShortOption(java.lang.String name)
-
getOptionGroup
public OptionGroup getOptionGroup(Option opt)
Returns the OptionGroup theopt
belongs to.- Parameters:
opt
- the option whose OptionGroup is being queried.- Returns:
- the OptionGroup if
opt
is part of an OptionGroup, otherwise return null
-
toString
public java.lang.String toString()
Dump state, suitable for debugging.- Overrides:
toString
in classjava.lang.Object
- Returns:
- the stringified form of this object
-
-