public static class CommandLine.Model.Messages extends Object
Example properties resource bundle:
# Usage Help Message Sections # --------------------------- # Numbered resource keys can be used to create multi-line sections. usage.headerHeading = This is my app. There are other apps like it but this one is mine.%n usage.header = header first line usage.header.0 = header second line usage.descriptionHeading = Description:%n usage.description.0 = first line usage.description.1 = second line usage.description.2 = third line usage.synopsisHeading = Usage:\u0020 # Leading whitespace is removed by default. Start with \u0020 to keep the leading whitespace. usage.customSynopsis.0 = Usage: ln [OPTION]... [-T] TARGET LINK_NAME (1st form) usage.customSynopsis.1 = \u0020 or: ln [OPTION]... TARGET (2nd form) usage.customSynopsis.2 = \u0020 or: ln [OPTION]... TARGET... DIRECTORY (3rd form) # Headings can contain the %n character to create multi-line values. usage.parameterListHeading = %nPositional parameters:%n usage.optionListHeading = %nOptions:%n usage.commandListHeading = %nCommands:%n usage.footerHeading = Powered by picocli%n usage.footer = footer # Option Descriptions # ------------------- # Use numbered keys to create multi-line descriptions. help = Show this help message and exit. version = Print version information and exit.
Resources for multiple commands can be specified in a single ResourceBundle. Keys and their value can be
shared by multiple commands (so you don't need to repeat them for every command), but keys can be prefixed with
fully qualified command name + "."
to specify different values for different commands.
The most specific key wins. For example:
jfrog.rt.usage.header = Artifactory commands jfrog.rt.config.usage.header = Configure Artifactory details. jfrog.rt.upload.usage.header = Upload files. jfrog.bt.usage.header = Bintray commands jfrog.bt.config.usage.header = Configure Bintray details. jfrog.bt.upload.usage.header = Upload files. # shared between all commands usage.footerHeading = Environment Variables: usage.footer.0 = footer line 0 usage.footer.1 = footer line 1
Constructor and Description |
---|
Messages(CommandLine.Model.CommandSpec spec,
ResourceBundle rb) |
Messages(CommandLine.Model.CommandSpec spec,
String baseName) |
Messages(CommandLine.Model.CommandSpec spec,
String baseName,
ResourceBundle rb) |
Modifier and Type | Method and Description |
---|---|
CommandLine.Model.CommandSpec |
commandSpec()
Returns the CommandSpec of this object, never
null . |
static CommandLine.Model.Messages |
copy(CommandLine.Model.CommandSpec spec,
CommandLine.Model.Messages original)
Returns a copy of the specified Messages object with the CommandSpec replaced by the specified one.
|
static boolean |
empty(CommandLine.Model.Messages messages)
Returns
true if the specified Messages is null , has a null ResourceBundle , or has a null parent Messages . |
String |
getString(String key,
String defaultValue)
Returns the String value found in the resource bundle for the specified key, or the specified default value if not found.
|
String[] |
getStringArray(String key,
String[] defaultValues)
Returns the String array value found in the resource bundle for the specified key, or the specified default value if not found.
|
CommandLine.Model.Messages |
parent() |
ResourceBundle |
resourceBundle()
Returns the ResourceBundle of this object or
null . |
static ResourceBundle |
resourceBundle(CommandLine.Model.Messages messages)
Returns the ResourceBundle of the specified Messages object or
null if the specified Messages object is null . |
String |
resourceBundleBaseName()
Returns the base name of the ResourceBundle of this object or
null . |
static String |
resourceBundleBaseName(CommandLine.Model.Messages messages)
Returns the ResourceBundle of the specified Messages object or
null if the specified Messages object is null . |
static void |
setLoadBundles(boolean loadBundles)
During annotation processing, resource bundles may not be available on the
classpath and thereby cause failures.
|
public Messages(CommandLine.Model.CommandSpec spec, String baseName)
public Messages(CommandLine.Model.CommandSpec spec, ResourceBundle rb)
public Messages(CommandLine.Model.CommandSpec spec, String baseName, ResourceBundle rb)
public CommandLine.Model.Messages parent()
public static final void setLoadBundles(boolean loadBundles)
loadBundles
- true if bundles should be loaded (default), false if bundles should not be loadedpublic static CommandLine.Model.Messages copy(CommandLine.Model.CommandSpec spec, CommandLine.Model.Messages original)
spec
- the CommandSpec of the returned Messagesoriginal
- the Messages object whose ResourceBundle to referencepublic static boolean empty(CommandLine.Model.Messages messages)
true
if the specified Messages
is null
, has a null ResourceBundle
, or has a null parent Messages
.public String getString(String key, String defaultValue)
key
- unqualified resource bundle key. This method will first try to find a value by qualifying the key with the command's fully qualified name,
and if not found, it will try with the unqualified key.defaultValue
- value to return if the resource bundle is null or empty, or if no value was found by the qualified or unqualified keypublic String[] getStringArray(String key, String[] defaultValues)
key.0
, key.1
, key.2
, etc.key
- unqualified resource bundle key. This method will first try to find a value by qualifying the key with the command's fully qualified name,
and if not found, it will try with the unqualified key.defaultValues
- value to return if the resource bundle is null or empty, or if no value was found by the qualified or unqualified keypublic static String resourceBundleBaseName(CommandLine.Model.Messages messages)
null
if the specified Messages object is null
.public static ResourceBundle resourceBundle(CommandLine.Model.Messages messages)
null
if the specified Messages object is null
.public String resourceBundleBaseName()
null
.public ResourceBundle resourceBundle()
null
.public CommandLine.Model.CommandSpec commandSpec()
null
.