Package picocli

Class CommandLine.Model.UsageMessageSpec

  • Enclosing class:
    CommandLine.Model

    public static class CommandLine.Model.UsageMessageSpec
    extends java.lang.Object
    Models the usage help message specification and can be used to customize the usage help message.

    This class provides two ways to customize the usage help message:

    • Change the text of the predefined sections (this may also be done declaratively using the annotations)
    • Add custom sections, or remove or re-order predefined sections

    The pre-defined sections have getters and setters that return a String (or array of Strings). For example: description() and description(String...) or header() and header(String...).

    Changing the section order, or adding custom sections can be accomplished with sectionKeys(List) and sectionMap(Map). This gives complete freedom on how a usage help message section is rendered, but it also means that the section renderer is responsible for all aspects of rendering the section, including layout and emitting ANSI escape codes. The CommandLine.Help.TextTable and CommandLine.Help.Ansi.Text classes, and the CommandLine.Help.Ansi.string(String) and CommandLine.Help.Ansi.text(String) methods may be useful.

    The usage help message is created more or less like this:

     // CommandLine.usage(...) or CommandLine.getUsageMessage(...)
     Help.ColorScheme colorScheme = Help.defaultColorScheme(Help.Ansi.AUTO);
     Help help = getHelpFactory().create(getCommandSpec(), colorScheme)
     StringBuilder result = new StringBuilder();
     for (String key : getHelpSectionKeys()) {
         IHelpSectionRenderer renderer = getHelpSectionMap().get(key);
         if (renderer != null) { result.append(renderer.render(help)); }
     }
     // return or print result
     

    Where the default help section map is constructed like this:

    
     // The default section renderers delegate to methods in Help for their implementation
     // (using Java 8 lambda notation for brevity):
     Map<String, IHelpSectionRenderer> sectionMap = new HashMap<>();
     sectionMap.put(SECTION_KEY_HEADER_HEADING,         help -> help.headerHeading());
     sectionMap.put(SECTION_KEY_HEADER,                 help -> help.header());
     sectionMap.put(SECTION_KEY_SYNOPSIS_HEADING,       help -> help.synopsisHeading());      //e.g. Usage:
     sectionMap.put(SECTION_KEY_SYNOPSIS,               help -> help.synopsis(help.synopsisHeadingLength())); //e.g. <cmd> [OPTIONS] <subcmd> [COMMAND-OPTIONS] [ARGUMENTS]
     sectionMap.put(SECTION_KEY_DESCRIPTION_HEADING,    help -> help.descriptionHeading());   //e.g. %nDescription:%n%n
     sectionMap.put(SECTION_KEY_DESCRIPTION,            help -> help.description());          //e.g. {"Converts foos to bars.", "Use options to control conversion mode."}
     sectionMap.put(SECTION_KEY_PARAMETER_LIST_HEADING, help -> help.parameterListHeading()); //e.g. %nPositional parameters:%n%n
     sectionMap.put(SECTION_KEY_PARAMETER_LIST,         help -> help.parameterList());        //e.g. [FILE...] the files to convert
     sectionMap.put(SECTION_KEY_OPTION_LIST_HEADING,    help -> help.optionListHeading());    //e.g. %nOptions:%n%n
     sectionMap.put(SECTION_KEY_OPTION_LIST,            help -> help.optionList());           //e.g. -h, --help   displays this help and exits
     sectionMap.put(SECTION_KEY_COMMAND_LIST_HEADING,   help -> help.commandListHeading());   //e.g. %nCommands:%n%n
     sectionMap.put(SECTION_KEY_COMMAND_LIST,           help -> help.commandList());          //e.g.    add       adds the frup to the frooble
     sectionMap.put(SECTION_KEY_EXIT_CODE_LIST_HEADING, help -> help.exitCodeListHeading());
     sectionMap.put(SECTION_KEY_EXIT_CODE_LIST,         help -> help.exitCodeList());
     sectionMap.put(SECTION_KEY_FOOTER_HEADING,         help -> help.footerHeading());
     sectionMap.put(SECTION_KEY_FOOTER,                 help -> help.footer());
     
    Since:
    3.0
    • Field Detail

      • DEFAULT_USAGE_WIDTH

        public static final int DEFAULT_USAGE_WIDTH
        Constant holding the default usage message width: 80.
        See Also:
        Constant Field Values
      • DEFAULT_USAGE_LONG_OPTIONS_WIDTH

        static final int DEFAULT_USAGE_LONG_OPTIONS_WIDTH
        See Also:
        Constant Field Values
      • DEFAULT_SYNOPSIS_INDENT

        private static final int DEFAULT_SYNOPSIS_INDENT
        See Also:
        Constant Field Values
      • DEFAULT_SYNOPSIS_AUTO_INDENT_THRESHOLD

        private static final double DEFAULT_SYNOPSIS_AUTO_INDENT_THRESHOLD
        See Also:
        Constant Field Values
      • MAX_SYNOPSIS_AUTO_INDENT_THRESHOLD

        private static final double MAX_SYNOPSIS_AUTO_INDENT_THRESHOLD
        See Also:
        Constant Field Values
      • DEFAULT_USAGE_AUTO_WIDTH

        static final java.lang.Boolean DEFAULT_USAGE_AUTO_WIDTH
        Constant Boolean holding the default setting for whether to attempt to adjust the width to the terminal width: .
      • DEFAULT_SYNOPSIS_HEADING

        static final java.lang.String DEFAULT_SYNOPSIS_HEADING
        Constant String holding the default synopsis heading: "Usage: ".
        See Also:
        Constant Field Values
      • DEFAULT_SYNOPSIS_SUBCOMMANDS

        static final java.lang.String DEFAULT_SYNOPSIS_SUBCOMMANDS
        Constant String holding the default synopsis subcommands: "[COMMAND]".
        See Also:
        Constant Field Values
      • DEFAULT_COMMAND_LIST_HEADING

        static final java.lang.String DEFAULT_COMMAND_LIST_HEADING
        Constant String holding the default command list heading: "Commands:%n".
        See Also:
        Constant Field Values
      • DEFAULT_REQUIRED_OPTION_MARKER

        static final char DEFAULT_REQUIRED_OPTION_MARKER
        Constant String holding the default string that separates options from option parameters: ' ' (32).
        See Also:
        Constant Field Values
      • DEFAULT_ABBREVIATE_SYNOPSIS

        static final java.lang.Boolean DEFAULT_ABBREVIATE_SYNOPSIS
        Constant Boolean holding the default setting for whether to abbreviate the synopsis: .
      • DEFAULT_SORT_OPTIONS

        static final java.lang.Boolean DEFAULT_SORT_OPTIONS
        Constant Boolean holding the default setting for whether to sort the options alphabetically: .
      • DEFAULT_SHOW_AT_FILE

        static final java.lang.Boolean DEFAULT_SHOW_AT_FILE
        Constant Boolean holding the default setting for whether to show an entry for @-files in the usage help message.
      • DEFAULT_SHOW_END_OF_OPTIONS

        static final java.lang.Boolean DEFAULT_SHOW_END_OF_OPTIONS
        Constant Boolean holding the default setting for whether to show an entry for the -- End of Options delimiter in the usage help message.
      • DEFAULT_SHOW_DEFAULT_VALUES

        static final java.lang.Boolean DEFAULT_SHOW_DEFAULT_VALUES
        Constant Boolean holding the default setting for whether to show default values in the usage help message: .
      • DEFAULT_HIDDEN

        static final java.lang.Boolean DEFAULT_HIDDEN
        Constant Boolean holding the default setting for whether this command should be listed in the usage help of the parent command: .
      • DEFAULT_ADJUST_CJK

        static final java.lang.Boolean DEFAULT_ADJUST_CJK
        Constant Boolean holding the default setting for whether line breaks should take wide CJK characters into account: .
      • DEFAULT_SINGLE_VALUE

        static final java.lang.String DEFAULT_SINGLE_VALUE
        See Also:
        Constant Field Values
      • DEFAULT_MULTI_LINE

        static final java.lang.String[] DEFAULT_MULTI_LINE
      • sectionKeys

        private java.util.List<java.lang.String> sectionKeys
      • description

        private java.lang.String[] description
      • customSynopsis

        private java.lang.String[] customSynopsis
      • header

        private java.lang.String[] header
      • footer

        private java.lang.String[] footer
      • abbreviateSynopsis

        private java.lang.Boolean abbreviateSynopsis
      • sortOptions

        private java.lang.Boolean sortOptions
      • showDefaultValues

        private java.lang.Boolean showDefaultValues
      • showAtFileInUsageHelp

        private java.lang.Boolean showAtFileInUsageHelp
      • showEndOfOptionsDelimiterInUsageHelp

        private java.lang.Boolean showEndOfOptionsDelimiterInUsageHelp
      • hidden

        private java.lang.Boolean hidden
      • autoWidth

        private java.lang.Boolean autoWidth
      • requiredOptionMarker

        private java.lang.Character requiredOptionMarker
      • headerHeading

        private java.lang.String headerHeading
      • synopsisHeading

        private java.lang.String synopsisHeading
      • synopsisSubcommandLabel

        private java.lang.String synopsisSubcommandLabel
      • synopsisAutoIndentThreshold

        private java.lang.Double synopsisAutoIndentThreshold
      • synopsisIndent

        private java.lang.Integer synopsisIndent
      • descriptionHeading

        private java.lang.String descriptionHeading
      • parameterListHeading

        private java.lang.String parameterListHeading
      • optionListHeading

        private java.lang.String optionListHeading
      • commandListHeading

        private java.lang.String commandListHeading
      • footerHeading

        private java.lang.String footerHeading
      • exitCodeListHeading

        private java.lang.String exitCodeListHeading
      • exitCodeListStrings

        private java.lang.String[] exitCodeListStrings
      • exitCodeList

        private java.util.Map<java.lang.String,​java.lang.String> exitCodeList
      • width

        private java.lang.Integer width
      • longOptionsMaxWidth

        private java.lang.Integer longOptionsMaxWidth
      • cachedTerminalWidth

        private java.lang.Integer cachedTerminalWidth
      • adjustLineBreaksForWideCJKCharacters

        private java.lang.Boolean adjustLineBreaksForWideCJKCharacters
    • Method Detail

      • width

        public CommandLine.Model.UsageMessageSpec width​(int newValue)
        Sets the maximum usage help message width to the specified value. Longer values are wrapped.
        Parameters:
        newValue - the new maximum usage help message width. Must be 55 or greater.
        Returns:
        this UsageMessageSpec for method chaining
        Throws:
        java.lang.IllegalArgumentException - if the specified width is less than 55
      • longOptionsMaxWidth

        public CommandLine.Model.UsageMessageSpec longOptionsMaxWidth​(int newValue)
        Sets the maximum usage help long options column max width to the specified value. This value controls the maximum width of the long options column: any positional parameter labels or long options that are longer than the specified value will overflow into the description column, and cause the description to be displayed on the next line.
        Parameters:
        newValue - the new maximum usage help long options column max width. Must be 20 or greater.
        Returns:
        this UsageMessageSpec for method chaining
        Throws:
        java.lang.IllegalArgumentException - if the specified long options column max is less than 20
        Since:
        4.2
      • getSysPropertyWidthOrDefault

        private int getSysPropertyWidthOrDefault​(int defaultWidth,
                                                 boolean detectTerminalSize)
      • shouldDetectTerminalSize

        private static boolean shouldDetectTerminalSize​(boolean autoWidthEnabledInApplication)
      • isNumeric

        private static boolean isNumeric​(java.lang.String userValue)
      • getTerminalWidth

        private static int getTerminalWidth()
      • detectTerminalWidth

        private static int detectTerminalWidth()
      • width

        public int width()
        Returns the maximum usage help message width. Derived from system property "picocli.usage.width" if set, otherwise returns the value set via the width(int) method, or if not set, the default width.
        Returns:
        the maximum usage help message width. Never returns less than 55.
      • longOptionsMaxWidth

        public int longOptionsMaxWidth()
        Returns the maximum usage help long options column max width to the specified value. This value controls the maximum width of the long options column: any positional parameter labels or long options that are longer than the specified value will overflow into the description column, and cause the description to be displayed on the next line.
        Returns:
        the new maximum usage help long options column max width. Always 20 or greater.
        Since:
        4.2
      • autoWidth

        public boolean autoWidth()
        Returns whether picocli should attempt to detect the terminal size and adjust the usage help message width to take the full terminal width. End users may enable this by setting system property "picocli.usage.width" to AUTO, and may disable this by setting this system property to a numeric value. This feature requires Java 7 or greater. The default is false.
        Since:
        4.0
        See Also:
        CommandLine.Command.usageHelpAutoWidth()
      • autoWidth

        public CommandLine.Model.UsageMessageSpec autoWidth​(boolean detectTerminalSize)
        Sets whether picocli should attempt to detect the terminal size and adjust the usage help message width to take the full terminal width. The default is false.
        Parameters:
        detectTerminalSize - whether picocli should attempt to detect the terminal size
        Since:
        4.0
        See Also:
        CommandLine.Command.usageHelpAutoWidth()
      • isCharCJK

        static boolean isCharCJK​(char c)
        Given a character, is this character considered to be a CJK character? Shamelessly stolen from StackOverflow where it was contributed by user Rakesh N. (Upvote! :-) )
        Parameters:
        c - Character to test
        Returns:
        true if the character is a CJK character
      • createHelpSectionRendererMap

        private java.util.Map<java.lang.String,​CommandLine.IHelpSectionRenderer> createHelpSectionRendererMap()
        Returns the help section renderers for the predefined section keys. see: sectionKeys()
      • sectionKeys

        public CommandLine.Model.UsageMessageSpec sectionKeys​(java.util.List<java.lang.String> keys)
        Sets the section keys in the order that the usage help message should render the sections.
        Since:
        3.9
        See Also:
        sectionKeys
      • sectionMap

        public java.util.Map<java.lang.String,​CommandLine.IHelpSectionRenderer> sectionMap()
        Returns the map of section keys and renderers used to construct the usage help message. The usage help message can be customized by adding, replacing and removing section renderers from this map. Sections can be reordered with the sectionKeys setter. Sections that are either not in this map or not in the list returned by sectionKeys are omitted.
        Since:
        3.9
        See Also:
        sectionKeys
      • helpFactory

        public CommandLine.Model.UsageMessageSpec helpFactory​(CommandLine.IHelpFactory helpFactory)
        Sets a new IHelpFactory to customize the usage help message.
        Parameters:
        helpFactory - the new help factory. Must be non-null.
        Returns:
        this UsageMessageSpec object, to allow method chaining
      • interpolate

        private java.lang.String interpolate​(java.lang.String value)
      • interpolate

        private java.lang.String[] interpolate​(java.lang.String[] values)
      • str

        private java.lang.String str​(java.lang.String localized,
                                     java.lang.String value,
                                     java.lang.String defaultValue)
      • arr

        private java.lang.String[] arr​(java.lang.String[] localized,
                                       java.lang.String[] value,
                                       java.lang.String[] defaultValue)
      • resourceStr

        private java.lang.String resourceStr​(java.lang.String key)
      • resourceArr

        private java.lang.String[] resourceArr​(java.lang.String key)
      • headerHeading

        public java.lang.String headerHeading()
        Returns the optional heading preceding the header section. Initialized from CommandLine.Command.headerHeading(), or "" (empty string).
      • header

        public java.lang.String[] header()
        Returns the optional header lines displayed at the top of the help message. For subcommands, the first header line is displayed in the list of commands. Values are initialized from CommandLine.Command.header() if the Command annotation is present, otherwise this is an empty array and the help message has no header. Applications may programmatically set this field to create a custom help message.
      • synopsisHeading

        public java.lang.String synopsisHeading()
        Returns the optional heading preceding the synopsis. Initialized from CommandLine.Command.synopsisHeading(), "Usage: " by default.
      • synopsisSubcommandLabel

        public java.lang.String synopsisSubcommandLabel()
        Returns the String representing the subcommands in the synopsis. Initialized from CommandLine.Command.synopsisSubcommandLabel(), "[COMMANDS]" by default.
        Since:
        4.0
      • synopsisAutoIndentThreshold

        public double synopsisAutoIndentThreshold()
        Returns the fraction of the usage help width() that is the threshold up to which the 2nd line and subsequent lines of a multi-line synopsis should be aligned to the end of the command name. The default value of this attribute is 0.5. If the length of the synopsis heading plus the length of the fully qualified command name exceeds this fraction of the width, the 2nd and subsequent rows of a multi-line synopsis will be aligned to the synopsisIndent() instead of the end of the command name.
        Since:
        4.0
      • synopsisIndent

        public int synopsisIndent()
        Returns the indentation to use on the 2nd line and subsequent lines of a multi-line synopsis when the length of the synopsis heading and the fully qualified command name exceed the width() times the synopsisAutoIndentThreshold(), -1 by default. A negative value for this option means that the 2nd line and subsequent lines are aligned to the synopsis heading length. A positive value means the exact number of spaces to indent for the 2nd line and subsequent lines of the synopsis.
        Since:
        4.0
      • abbreviateSynopsis

        public boolean abbreviateSynopsis()
        Returns whether the synopsis line(s) should show an abbreviated synopsis without detailed option names.
      • customSynopsis

        public java.lang.String[] customSynopsis()
        Returns the optional custom synopsis lines to use instead of the auto-generated synopsis. Initialized from CommandLine.Command.customSynopsis() if the Command annotation is present, otherwise this is an empty array and the synopsis is generated. Applications may programmatically set this field to create a custom help message.
      • description

        public java.lang.String[] description()
        Returns the optional text lines to use as the description of the help message, displayed between the synopsis and the options list. Initialized from CommandLine.Command.description() if the Command annotation is present, otherwise this is an empty array and the help message has no description. Applications may programmatically set this field to create a custom help message.
      • sortOptions

        public boolean sortOptions()
        Returns whether the options list in the usage help message should be sorted alphabetically.
      • requiredOptionMarker

        public char requiredOptionMarker()
        Returns the character used to prefix required options in the options list.
      • showDefaultValues

        public boolean showDefaultValues()
        Returns whether the options list in the usage help message should show default values for all non-boolean options.
      • hidden

        public boolean hidden()
        Returns whether this command should be hidden from the usage help message of the parent command.
        Returns:
        true if this command should not appear in the usage help message of the parent command
      • commandListHeading

        public java.lang.String commandListHeading()
        Returns the optional heading preceding the subcommand list. Initialized from CommandLine.Command.commandListHeading(). "Commands:%n" by default.
      • exitCodeListHeading

        public java.lang.String exitCodeListHeading()
        Returns the optional heading preceding the exit codes section, may contain "%n" line separators. "" (empty string) by default.
      • exitCodeList

        public java.util.Map<java.lang.String,​java.lang.String> exitCodeList()
        Returns an unmodifiable map with values to be displayed in the exit codes section: keys are exit codes, values are descriptions. Descriptions may contain "%n" line separators. Callers may be interested in the keyValuesMap method for creating a map from a list of "key:value" Strings.

        This may be configured in a resource bundle by listing up multiple "key:value" pairs. For example:

         usage.exitCodeList.0 = 0:Successful program execution.
         usage.exitCodeList.1 = 64:Invalid input: an unknown option or invalid parameter was specified.
         usage.exitCodeList.2 = 70:Execution exception: an exception occurred while executing the business logic.
         
        Returns:
        an unmodifiable map with values to be displayed in the exit codes section, or an empty map if no exit codes are registered.
        Since:
        4.0
        See Also:
        keyValuesMap(String...)
      • keyValuesMap

        public static java.util.Map<java.lang.String,​java.lang.String> keyValuesMap​(java.lang.String... entries)
        Creates and returns a Map that contains an entry for each specified String that is in "key:value" format.
        Parameters:
        entries - the strings to process; values that are not in "key:value" format are ignored
        Returns:
        a Map with an entry for each line, preserving the input order
        Since:
        4.0
      • footerHeading

        public java.lang.String footerHeading()
        Returns the optional heading preceding the footer section. Initialized from CommandLine.Command.footerHeading(), or "" (empty string).
      • footer

        public java.lang.String[] footer()
        Returns the optional footer text lines displayed at the bottom of the help message. Initialized from CommandLine.Command.footer() if the Command annotation is present, otherwise this is an empty array and the help message has no footer. Applications may programmatically set this field to create a custom help message.
      • header

        public CommandLine.Model.UsageMessageSpec header​(java.lang.String... header)
        Sets the optional header lines displayed at the top of the help message. For subcommands, the first header line is displayed in the list of commands.
        Returns:
        this UsageMessageSpec for method chaining
      • synopsisHeading

        public CommandLine.Model.UsageMessageSpec synopsisHeading​(java.lang.String newValue)
        Sets the optional heading preceding the synopsis.
        Returns:
        this UsageMessageSpec for method chaining
      • synopsisSubcommandLabel

        public CommandLine.Model.UsageMessageSpec synopsisSubcommandLabel​(java.lang.String newValue)
        Sets the String representing the subcommands in the synopsis.
        Returns:
        this UsageMessageSpec for method chaining
        Since:
        4.0
      • synopsisAutoIndentThreshold

        public CommandLine.Model.UsageMessageSpec synopsisAutoIndentThreshold​(double newValue)
        Sets the fraction of the usage help width() that is the threshold up to which the 2nd line and subsequent lines of a multi-line synopsis should be aligned to the end of the command name. The default value of this attribute is 0.5. If the length of the synopsis heading plus the length of the fully qualified command name exceeds this fraction of the width, the 2nd and subsequent rows of a multi-line synopsis will be aligned to the synopsisIndent() instead of the end of the command name.
        Parameters:
        newValue - the new threshold value. Must be a value between 0.0 and 0.9, inclusive
        Returns:
        this UsageMessageSpec for method chaining
        Throws:
        java.lang.IllegalArgumentException - if the specified value is less than 0.0 or greater than 0.9
        Since:
        4.0
      • synopsisIndent

        public CommandLine.Model.UsageMessageSpec synopsisIndent​(int newValue)
        Sets the indentation to use on the 2nd line and subsequent lines of a multi-line synopsis when the length of the synopsis heading and the fully qualified command name exceed the synopsisAutoIndentThreshold() fraction of the width(), -1 by default. A negative value for this option means that the 2nd line and subsequent lines are aligned to the synopsis heading length. A positive value means the exact number of spaces to indent for the 2nd line and subsequent lines of the synopsis.
        Returns:
        this UsageMessageSpec for method chaining
        Since:
        4.0
      • abbreviateSynopsis

        public CommandLine.Model.UsageMessageSpec abbreviateSynopsis​(boolean newValue)
        Sets whether the synopsis line(s) should show an abbreviated synopsis without detailed option names.
        Returns:
        this UsageMessageSpec for method chaining
      • customSynopsis

        public CommandLine.Model.UsageMessageSpec customSynopsis​(java.lang.String... customSynopsis)
        Sets the optional custom synopsis lines to use instead of the auto-generated synopsis.
        Returns:
        this UsageMessageSpec for method chaining
      • descriptionHeading

        public CommandLine.Model.UsageMessageSpec descriptionHeading​(java.lang.String newValue)
        Sets the heading preceding the description section.
        Returns:
        this UsageMessageSpec for method chaining
      • description

        public CommandLine.Model.UsageMessageSpec description​(java.lang.String... description)
        Sets the optional text lines to use as the description of the help message, displayed between the synopsis and the options list.
        Returns:
        this UsageMessageSpec for method chaining
      • parameterListHeading

        public CommandLine.Model.UsageMessageSpec parameterListHeading​(java.lang.String newValue)
        Sets the optional heading preceding the parameter list.
        Returns:
        this UsageMessageSpec for method chaining
      • optionListHeading

        public CommandLine.Model.UsageMessageSpec optionListHeading​(java.lang.String newValue)
        Sets the heading preceding the options list.
        Returns:
        this UsageMessageSpec for method chaining
      • sortOptions

        public CommandLine.Model.UsageMessageSpec sortOptions​(boolean newValue)
        Sets whether the options list in the usage help message should be sorted alphabetically.
        Returns:
        this UsageMessageSpec for method chaining
      • requiredOptionMarker

        public CommandLine.Model.UsageMessageSpec requiredOptionMarker​(char newValue)
        Sets the character used to prefix required options in the options list.
        Returns:
        this UsageMessageSpec for method chaining
      • showDefaultValues

        public CommandLine.Model.UsageMessageSpec showDefaultValues​(boolean newValue)
        Sets whether the options list in the usage help message should show default values for all non-boolean options.
        Returns:
        this UsageMessageSpec for method chaining
      • hidden

        public CommandLine.Model.UsageMessageSpec hidden​(boolean value)
        Set the hidden flag on this command to control whether to show or hide it in the help usage text of the parent command.
        Parameters:
        value - enable or disable the hidden flag
        Returns:
        this UsageMessageSpec for method chaining
        See Also:
        CommandLine.Command.hidden()
      • commandListHeading

        public CommandLine.Model.UsageMessageSpec commandListHeading​(java.lang.String newValue)
        Sets the optional heading preceding the subcommand list.
        Returns:
        this UsageMessageSpec for method chaining
      • exitCodeListHeading

        public CommandLine.Model.UsageMessageSpec exitCodeListHeading​(java.lang.String newValue)
        Sets the optional heading preceding the exit codes section, may contain "%n" line separators. "" (empty string) by default.
        Since:
        4.0
      • exitCodeList

        public CommandLine.Model.UsageMessageSpec exitCodeList​(java.util.Map<java.lang.String,​java.lang.String> newValue)
        Sets the values to be displayed in the exit codes section: keys are exit codes, values are descriptions. Descriptions may contain "%n" line separators.

        This may be configured in a resource bundle by listing up multiple "key:value" pairs. For example:

         usage.exitCodeList.0 = 0:Successful program execution.
         usage.exitCodeList.1 = 64:Invalid input: an unknown option or invalid parameter was specified.
         usage.exitCodeList.2 = 70:Execution exception: an exception occurred while executing the business logic.
         
        Parameters:
        newValue - a map with values to be displayed in the exit codes section
        Since:
        4.0
        See Also:
        keyValuesMap(String...)
      • footerHeading

        public CommandLine.Model.UsageMessageSpec footerHeading​(java.lang.String newValue)
        Sets the optional heading preceding the footer section.
        Returns:
        this UsageMessageSpec for method chaining
      • footer

        public CommandLine.Model.UsageMessageSpec footer​(java.lang.String... footer)
        Sets the optional footer text lines displayed at the bottom of the help message.
        Returns:
        this UsageMessageSpec for method chaining
      • adjustLineBreaksForWideCJKCharacters

        public boolean adjustLineBreaksForWideCJKCharacters()
        Returns whether line breaks should take wide Chinese, Japanese and Korean characters into account for line-breaking purposes.
        Returns:
        true if wide Chinese, Japanese and Korean characters are counted as double the size of other characters for line-breaking purposes
        Since:
        4.0
      • adjustLineBreaksForWideCJKCharacters

        public CommandLine.Model.UsageMessageSpec adjustLineBreaksForWideCJKCharacters​(boolean adjustForWideChars)
        Sets whether line breaks should take wide Chinese, Japanese and Korean characters into account, and returns this UsageMessageSpec.
        Parameters:
        adjustForWideChars - if true, wide Chinese, Japanese and Korean characters are counted as double the size of other characters for line-breaking purposes
        Since:
        4.0