Class BashCompletionGenerator<T>

    • Field Detail

      • withDebugging

        private final boolean withDebugging
    • Constructor Detail

      • BashCompletionGenerator

        public BashCompletionGenerator()
      • BashCompletionGenerator

        public BashCompletionGenerator​(boolean includeHidden,
                                       boolean enableDebugging)
        Creates a new completion generator
        Parameters:
        enableDebugging - Whether to enable debugging, when true the generated script will do set -o xtrace in its functions and set +o xtrace at the end of its functions
    • Method Detail

      • usage

        public void usage​(GlobalMetadata<T> global,
                          java.io.OutputStream output)
                   throws java.io.IOException
        Description copied from interface: GlobalUsageGenerator
        Generate the help and output it to the stream
        Parameters:
        global - Global metadata
        output - Stream to output to
        Throws:
        java.io.IOException - Thrown if there is a problem generating usage output
      • generateCommandFunctions

        private void generateCommandFunctions​(GlobalMetadata<T> global,
                                              java.io.Writer writer)
                                       throws java.io.IOException
        Throws:
        java.io.IOException
      • generateGroupFunctions

        private void generateGroupFunctions​(GlobalMetadata<T> global,
                                            java.io.Writer writer)
                                     throws java.io.IOException
        Throws:
        java.io.IOException
      • writeHeader

        private void writeHeader​(java.io.Writer writer)
                          throws java.io.IOException
        Throws:
        java.io.IOException
      • writeHelperFunctions

        private void writeHelperFunctions​(java.io.Writer writer)
                                   throws java.io.IOException
        Throws:
        java.io.IOException
      • writeCommandCase

        private void writeCommandCase​(java.io.Writer writer,
                                      GlobalMetadata<T> global,
                                      CommandGroupMetadata group,
                                      CommandMetadata command,
                                      int indent,
                                      boolean isNestedFunction)
                               throws java.io.IOException
        Throws:
        java.io.IOException
      • writeGroupCase

        private void writeGroupCase​(java.io.Writer writer,
                                    GlobalMetadata<T> global,
                                    CommandGroupMetadata group,
                                    int indent)
                             throws java.io.IOException
        Throws:
        java.io.IOException
      • writeGroupFunctionCall

        private void writeGroupFunctionCall​(java.io.Writer writer,
                                            GlobalMetadata<T> global,
                                            CommandGroupMetadata group,
                                            int indent)
                                     throws java.io.IOException
        Throws:
        java.io.IOException
      • generateGroupCompletionFunction

        private void generateGroupCompletionFunction​(java.io.Writer writer,
                                                     GlobalMetadata<T> global,
                                                     CommandGroupMetadata group)
                                              throws java.io.IOException
        Throws:
        java.io.IOException
      • indent

        private void indent​(java.io.Writer writer,
                            int indent)
                     throws java.io.IOException
        Throws:
        java.io.IOException
      • repeat

        private void repeat​(java.io.Writer writer,
                            int count,
                            char c)
                     throws java.io.IOException
        Throws:
        java.io.IOException
      • writeWordListVariable

        private void writeWordListVariable​(java.io.Writer writer,
                                           int indent,
                                           java.lang.String varName,
                                           java.util.Iterator<java.lang.String> words)
                                    throws java.io.IOException
        Throws:
        java.io.IOException
      • writeFunctionName

        private void writeFunctionName​(java.io.Writer writer,
                                       GlobalMetadata<T> global,
                                       boolean declare)
                                throws java.io.IOException
        Throws:
        java.io.IOException
      • writeGroupFunctionName

        private void writeGroupFunctionName​(java.io.Writer writer,
                                            GlobalMetadata<T> global,
                                            CommandGroupMetadata group,
                                            boolean declare)
                                     throws java.io.IOException
        Throws:
        java.io.IOException
      • writeCompletionGeneration

        private void writeCompletionGeneration​(java.io.Writer writer,
                                               int indent,
                                               boolean isNestedFunction,
                                               BashCompletion completion,
                                               java.lang.String... varNames)
                                        throws java.io.IOException
        Throws:
        java.io.IOException
      • bashize

        private java.lang.String bashize​(java.lang.String value)
      • getCompletionData

        protected BashCompletion getCompletionData​(OptionMetadata option)
        Gets the completion info for an option
        Parameters:
        option - Option
        Returns:
        Completion data, null if none specified
      • getCompletionData

        protected BashCompletion getCompletionData​(ArgumentsMetadata arguments)
        Gets the completion info for arguments
        Parameters:
        arguments - Arguments
        Returns:
        Completion data, null if none specified
      • getCompletionData

        protected BashCompletion getCompletionData​(java.util.Collection<Accessor> accessors)