Module org.jline

Interface ConsoleEngine

    • Method Detail

      • plainCommand

        static String plainCommand​(String command)
        Removes the command name first character if it is colon
        Parameters:
        command - the name of the command to complete
        Returns:
        command name without starting colon
      • setLineReader

        void setLineReader​(LineReader reader)
        Sets lineReader
        Parameters:
        reader - LineReader
      • setSystemRegistry

        void setSystemRegistry​(SystemRegistry systemRegistry)
        Sets systemRegistry
        Parameters:
        systemRegistry - SystemRegistry
      • expandParameters

        Object[] expandParameters​(String[] args)
                           throws Exception
        Substituting args references with their values.
        Parameters:
        args - the arguments to be expanded
        Returns:
        expanded arguments
        Throws:
        Exception - in case of error
      • expandCommandLine

        String expandCommandLine​(String line)
        Substitutes command line with system registry invoke method call.
        Parameters:
        line - command line to be expanded
        Returns:
        expanded command line
      • expandToList

        String expandToList​(List<String> params)
        Expands parameter list to string
        Parameters:
        params - list of script parameters
        Returns:
        expanded parameters list
      • scripts

        Map<String,​Boolean> scripts()
        Returns all scripts found from PATH
        Returns:
        map keys have script file names and value is true if it is console script
      • setScriptExtension

        void setScriptExtension​(String extension)
        Sets file name extension used by console scripts
        Parameters:
        extension - console script file extension
      • hasAlias

        boolean hasAlias​(String name)
        Returns true if alias 'name' exists
        Parameters:
        name - alias name
        Returns:
        true if alias exists
      • getAlias

        String getAlias​(String name)
        Returns alias 'name' value
        Parameters:
        name - alias name
        Returns:
        value of alias
      • getPipes

        Map<String,​List<String>> getPipes()
        Returns defined pipes
        Returns:
        map of defined pipes
      • getNamedPipes

        List<String> getNamedPipes()
        Returns named pipe names
        Returns:
        list of named pipe names
      • scriptCompleters

        List<Completer> scriptCompleters()
        Returns script and variable completers
        Returns:
        script and variable completers
      • persist

        void persist​(Path file,
                     Object object)
        Persist object to file
        Parameters:
        file - file where object should be written
        object - object to persist
      • slurp

        Object slurp​(Path file)
              throws IOException
        Read object from file
        Parameters:
        file - file from where object should be read
        Returns:
        object
        Throws:
        IOException - in case of error
      • consoleOption

        <T> T consoleOption​(String option,
                            T defval)
        Read console option value
        Type Parameters:
        T - option type
        Parameters:
        option - option name
        defval - default value
        Returns:
        option value
      • execute

        Object execute​(String name,
                       String rawLine,
                       String[] args)
                throws Exception
        Executes command line that does not contain known command by the system registry. If the line is neither JLine or ScriptEngine script it will be evaluated as ScriptEngine statement.
        Parameters:
        name - parsed command/script name
        rawLine - raw command line
        args - parsed arguments of the command
        Returns:
        command line execution result
        Throws:
        Exception - in case of error
      • execute

        default Object execute​(File script)
                        throws Exception
        Executes either JLine or ScriptEngine script.
        Parameters:
        script - script file
        Returns:
        script execution result
        Throws:
        Exception - in case of error
      • execute

        Object execute​(File script,
                       String rawLine,
                       String[] args)
                throws Exception
        Executes either JLine or ScriptEngine script.
        Parameters:
        script - script file
        rawLine - raw command line
        args - script arguments
        Returns:
        script execution result
        Throws:
        Exception - in case of error
      • postProcess

        ConsoleEngine.ExecutionResult postProcess​(String line,
                                                  Object result,
                                                  String output)
        Post processes execution result. If result is to be assigned to the console variable then method will return null.
        Parameters:
        line - command line
        result - command result to process
        output - command redirected output
        Returns:
        processed result
      • postProcess

        ConsoleEngine.ExecutionResult postProcess​(Object result)
        Post processes execution result.
        Parameters:
        result - command result to process
        Returns:
        processed result
      • trace

        void trace​(Object object)
        Parameters:
        object - object to print
      • println

        void println​(Object object)
        Print object.
        Parameters:
        object - object to print
      • putVariable

        void putVariable​(String name,
                         Object value)
        Create console variable
        Parameters:
        name - name of the variable
        value - value of the variable
      • getVariable

        Object getVariable​(String name)
        Get variable value
        Parameters:
        name - name of the variable
        Returns:
        variable value
      • hasVariable

        boolean hasVariable​(String name)
        Test if variable with name exists
        Parameters:
        name - name of the variable
        Returns:
        true if variable with name exists
      • purge

        void purge()
        Delete temporary console variables
      • executeWidget

        boolean executeWidget​(Object function)
        Execute widget function
        Parameters:
        function - to execute
        Returns:
        true on success
      • isExecuting

        boolean isExecuting()
        Returns:
        true if consoleEngine is executing script