Class CMDImpl<C extends IComponent<C>>
- java.lang.Object
-
- io.ciera.runtime.summit.util.Utility<C>
-
- io.ciera.runtime.summit.util.impl.CMDImpl<C>
-
- All Implemented Interfaces:
IActionHome<C>
,CMD
public class CMDImpl<C extends IComponent<C>> extends Utility<C> implements CMD
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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.-
Methods inherited from class io.ciera.runtime.summit.util.Utility
context, getRunContext
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.ciera.runtime.summit.application.IActionHome
warn
-
-
-
-
Constructor Detail
-
CMDImpl
public CMDImpl(C context)
-
-
Method Detail
-
get_flag
public boolean get_flag(String name) throws XtumlException
Description copied from interface:CMD
Get the value of a registered command line flag.- Specified by:
get_flag
in interfaceCMD
- Parameters:
name
- the name of the flag- Returns:
- true if the flag was passed as a command line argument, false if otherwise
- Throws:
XtumlException
- 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.
-
get_value
public String get_value(String name) throws XtumlException
Description copied from interface:CMD
Get the value of a registered command line value.- Specified by:
get_value
in interfaceCMD
- Parameters:
name
- the name of the value- Returns:
- the value of the option passed on the command line or the registered default value if not present and not required
- Throws:
XtumlException
- 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.
-
read_command_line
public void read_command_line() throws XtumlException
Description copied from interface:CMD
Parse and validate the command line arguments based on the previously registered flags and values. If an excption is thrown, the usage is printed to the command line and the application will exit.- Specified by:
read_command_line
in interfaceCMD
- Throws:
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.
-
register_flag
public void register_flag(String name, String usage) throws XtumlException
Description copied from interface:CMD
Register a command line flag.- Specified by:
register_flag
in interfaceCMD
- Parameters:
name
- the name of the flagusage
- the help text to display in the usage- Throws:
XtumlException
- if the command line has already been read, the flag name has already been registered, or if the flag name is invalid.
-
register_value
public void register_value(String name, String value_name, String usage, String default_value, boolean required) throws XtumlException
Description copied from interface:CMD
Register a command line value. If the flag is required, thedefault_value
parameter is ignored.- Specified by:
register_value
in interfaceCMD
- Parameters:
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 required- Throws:
XtumlException
- if the command line has already been read, the option name has already been registered, or if the option name is invalid.
-
-