public class CMDImpl<C extends IComponent<C>> extends Utility<C> implements CMD
Modifier and Type | Method and Description |
---|---|
boolean |
get_flag(String name)
Get the value of a registered command line flag.
|
String |
get_value(String name)
Get the value of a registered command line value.
|
void |
read_command_line()
Parse and validate the command line arguments based on the previously
registered flags and values.
|
void |
register_flag(String name,
String usage)
Register a command line flag.
|
void |
register_value(String name,
String value_name,
String usage,
String default_value,
boolean required)
Register a command line value.
|
context, getRunContext
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
warn
public CMDImpl(C context)
public boolean get_flag(String name) throws XtumlException
CMD
get_flag
in interface CMD
name
- the name of the flagXtumlException
- if the command line has not been read, the flag
name has not been registered, or if the flag has been registered as a
value.public String get_value(String name) throws XtumlException
CMD
get_value
in interface CMD
name
- the name of the valueXtumlException
- if the command line has not been read, the value
name has not been registered, or if the value has been registered as a
flag.public void read_command_line() throws XtumlException
CMD
read_command_line
in interface CMD
XtumlException
- if the command line has already been readXtumlInterruptedException
- if the command line arguments are
incorrectly formatted or if an option that requires a value does not
provide a value.public void register_flag(String name, String usage) throws XtumlException
CMD
register_flag
in interface CMD
name
- the name of the flagusage
- the help text to display in the usageXtumlException
- if the command line has already been read, the flag
name has already been registered, or if the flag name is invalid.public void register_value(String name, String value_name, String usage, String default_value, boolean required) throws XtumlException
CMD
default_value
parameter is ignored.register_value
in interface CMD
name
- the name of the valuevalue_name
- the placeholder name of the value to display in the
usageusage
- the help text to display in the usagedefault_value
- the default value of the option if not required and
no value is specifiedrequired
- whether or not a value is requiredXtumlException
- if the command line has already been read, the option
name has already been registered, or if the option name is invalid.Copyright © 2021. All rights reserved.