Class AbstractCommandUsageGenerator

    • Field Detail

      • exitCodeComparator

        private final java.util.Comparator<? super java.util.Map.Entry<java.lang.Integer,​java.lang.String>> exitCodeComparator
    • Constructor Detail

      • AbstractCommandUsageGenerator

        public AbstractCommandUsageGenerator()
      • AbstractCommandUsageGenerator

        public AbstractCommandUsageGenerator​(boolean includeHidden)
      • AbstractCommandUsageGenerator

        public AbstractCommandUsageGenerator​(java.util.Comparator<? super OptionMetadata> optionComparator)
      • AbstractCommandUsageGenerator

        public AbstractCommandUsageGenerator​(java.util.Comparator<? super OptionMetadata> optionComparator,
                                             boolean includeHidden)
      • AbstractCommandUsageGenerator

        public AbstractCommandUsageGenerator​(java.util.Comparator<? super HelpHint> hintComparator,
                                             java.util.Comparator<? super OptionMetadata> optionComparator,
                                             java.util.Comparator<? super java.util.Map.Entry<java.lang.Integer,​java.lang.String>> exitCodeComparator,
                                             boolean includeHidden)
    • Method Detail

      • usage

        public <T> void usage​(CommandMetadata command,
                              ParserMetadata<T> parserConfig,
                              java.io.OutputStream output)
                       throws java.io.IOException
        Description copied from interface: CommandUsageGenerator
        Generates the help output to the provided output stream
        Specified by:
        usage in interface CommandUsageGenerator
        Parameters:
        command - Command Metadata
        parserConfig - Parser configuration
        output - Output Stream
        Throws:
        java.io.IOException
      • usage

        public <T> void usage​(java.lang.String programName,
                              java.lang.String[] groupNames,
                              java.lang.String commandName,
                              CommandMetadata command,
                              ParserMetadata<T> parserConfig)
                       throws java.io.IOException
        Description copied from interface: CommandUsageGenerator
        Generate the help and output it on standard out
        Specified by:
        usage in interface CommandUsageGenerator
        Type Parameters:
        T - Command type
        Parameters:
        programName - Program Name
        groupNames - Group Name(s)
        commandName - Command Name
        command - Command Metadata
        parserConfig - Parser configuration, if null is passed then the parser configuration is automatically determined based on the command class for which we are producing help
        Throws:
        java.io.IOException - Thrown if there is a problem generating usage output
      • sortExitCodes

        protected java.util.List<java.util.Map.Entry<java.lang.Integer,​java.lang.String>> sortExitCodes​(java.util.List<java.util.Map.Entry<java.lang.Integer,​java.lang.String>> exitCodes)
        Sorts the exit codes assuming a non-null comparator was provided at instantiation time
        Parameters:
        exitCodes - Exit codes
        Returns:
        Sorted exit codes
      • findHelpSections

        protected void findHelpSections​(CommandMetadata command,
                                        java.util.List<HelpSection> preSections,
                                        java.util.List<HelpSection> postSections)
        Finds the help sections
        Parameters:
        command - Command meta-data
        preSections - Sections that should be placed before base content
        postSections - Sections that should be placed after base content