Package org.daisy.cli
Class AbstractUI
java.lang.Object
org.daisy.cli.AbstractUI
- Direct Known Subclasses:
BasicUI
Provides an abstract base for command line UI's.
- Author:
- Joel HÃ¥kansson
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Provides the information needed by an application argument.static class
Provides a definition, that is a name and a descriptionstatic enum
Provides exit codes to be used by implementing classes.static class
Provides the information needed by an optional argument. -
Field Summary
Modifier and TypeFieldDescriptionstatic final String
Prefix used for required arguments in the arguments map -
Constructor Summary
ConstructorDescriptionCreates a new AbstractUI using the default key/value delimiter '=' and the default optional argument prefix '-' -
Method Summary
Modifier and TypeMethodDescriptionvoid
Displays a help text for the UI based on the implementation of the methods getName, getOptionalArguments and getRequiredArguments.static void
static void
exitWithCode
(AbstractUI.ExitCode e, String message) void
expandShortForm
(Map<String, String> map, String key, ShortFormResolver resolver) Expands the short form of the value with the given key in the provided map using the specified resolver.getDefinitionList
(FactoryCatalog<? extends Factory> catalog, ShortFormResolver resolver) Creates a list of definitions based on the contents of the supplied FactoryCatalog.abstract String
getName()
Gets the name for the UIgetOptional
(String[] args) abstract List<AbstractUI.OptionalArgument>
Gets optional argumentsgetRequired
(String[] args) abstract List<AbstractUI.Argument>
Gets required argumentsvoid
setKeyValueDelimiter
(String value) Sets the delimiter to use between key and value in the argument strings passed to the UI.void
setOptionalArgumentPrefix
(String value) Sets the optional argument prefix to use in argument strings passed to the UI.Converts a string based definition of UI arguments, typically passed by the main method, into a key-value map as described by displayHelp
-
Field Details
-
ARG_PREFIX
Prefix used for required arguments in the arguments map- See Also:
-
-
Constructor Details
-
AbstractUI
public AbstractUI()Creates a new AbstractUI using the default key/value delimiter '=' and the default optional argument prefix '-'
-
-
Method Details
-
expandShortForm
Expands the short form of the value with the given key in the provided map using the specified resolver.- Parameters:
map
-key
-resolver
-
-
getDefinitionList
public List<AbstractUI.Definition> getDefinitionList(FactoryCatalog<? extends Factory> catalog, ShortFormResolver resolver) Creates a list of definitions based on the contents of the supplied FactoryCatalog.- Parameters:
catalog
- the catalog to create definitions forresolver
-- Returns:
- returns a list of definitions
-
setKeyValueDelimiter
Sets the delimiter to use between key and value in the argument strings passed to the UI.- Parameters:
value
- the delimiter to use
-
setOptionalArgumentPrefix
Sets the optional argument prefix to use in argument strings passed to the UI.- Parameters:
value
- the prefix to use
-
getName
Gets the name for the UI- Returns:
- returns the UI name
-
getRequiredArguments
Gets required arguments- Returns:
- returns a list of required arguments that can be passed to the UI on startup
-
getOptionalArguments
Gets optional arguments- Returns:
- returns a list of optional arguments that can be passed to the UI on startup
-
toMap
Converts a string based definition of UI arguments, typically passed by the main method, into a key-value map as described by displayHelp- Parameters:
args
- the arguments passed to the application- Returns:
- returns a map of application arguments
-
getOptional
-
getRequired
-
exitWithCode
-
exitWithCode
-
displayHelp
Displays a help text for the UI based on the implementation of the methods getName, getOptionalArguments and getRequiredArguments.- Parameters:
ps
- The print stream to use, typically System.out
-