Class Commands

java.lang.Object
org.jline.builtins.Commands

public class Commands extends Object
Provides built-in commands for JLine applications.

This class contains implementations of common terminal commands and utilities such as:

  • tmux - Terminal multiplexer
  • nano - Text editor
  • less - View file contents with pagination
  • history - Display and manage command history
  • complete - Edit command-specific tab completions
  • widget - Manipulate line reader widgets
  • keymap - Manipulate keymaps
  • setopt/unsetopt - Set/unset line reader options
  • setvar - Set line reader variables
  • colors - View color tables and ANSI styles
  • highlighter - Manage syntax highlighting themes

These commands can be used to provide a familiar command-line interface in JLine-based applications.

  • Constructor Details

    • Commands

      public Commands()
  • Method Details

    • tmux

      public static void tmux(org.jline.terminal.Terminal terminal, PrintStream out, PrintStream err, Supplier<Object> getter, Consumer<Object> setter, Consumer<org.jline.terminal.Terminal> runner, String[] argv) throws Exception
      Implements a terminal multiplexer similar to tmux.
      Parameters:
      terminal - the terminal to use
      out - the output stream
      err - the error stream
      getter - supplier to get the current tmux instance
      setter - consumer to set the current tmux instance
      runner - consumer to run a terminal
      argv - command arguments
      Throws:
      Exception - if an error occurs
    • nano

      public static void nano(org.jline.terminal.Terminal terminal, PrintStream out, PrintStream err, Path currentDir, String[] argv) throws Exception
      Launches the nano text editor with the specified arguments. This is a convenience method that calls nano(Terminal, PrintStream, PrintStream, Path, String[], ConfigurationPath) with a null ConfigurationPath.
      Parameters:
      terminal - the terminal to use
      out - the output stream
      err - the error stream
      currentDir - the current directory
      argv - command arguments
      Throws:
      Exception - if an error occurs
    • nano

      public static void nano(org.jline.terminal.Terminal terminal, PrintStream out, PrintStream err, Path currentDir, String[] argv, ConfigurationPath configPath) throws Exception
      Launches the nano text editor with the specified arguments.
      Parameters:
      terminal - the terminal to use
      out - the output stream
      err - the error stream
      currentDir - the current directory
      argv - command arguments
      configPath - the configuration path or null for default
      Throws:
      Exception - if an error occurs
    • less

      public static void less(org.jline.terminal.Terminal terminal, InputStream in, PrintStream out, PrintStream err, Path currentDir, Object[] argv) throws Exception
      Launches the less pager with the specified arguments. This is a convenience method that calls less(Terminal, InputStream, PrintStream, PrintStream, Path, Object[], ConfigurationPath) with a null ConfigurationPath.
      Parameters:
      terminal - the terminal to use
      in - the input stream
      out - the output stream
      err - the error stream
      currentDir - the current directory
      argv - command arguments
      Throws:
      Exception - if an error occurs
    • less

      public static void less(org.jline.terminal.Terminal terminal, InputStream in, PrintStream out, PrintStream err, Path currentDir, Object[] argv, ConfigurationPath configPath) throws Exception
      Launches the less pager with the specified arguments.
      Parameters:
      terminal - the terminal to use
      in - the input stream
      out - the output stream
      err - the error stream
      currentDir - the current directory
      argv - command arguments (can be String or Source objects)
      configPath - the configuration path or null for default
      Throws:
      Exception - if an error occurs
    • findFiles

      protected static List<Path> findFiles(Path root, String files) throws IOException
      Finds files matching a glob pattern.
      Parameters:
      root - the root directory to search from
      files - the glob pattern to match
      Returns:
      a list of matching paths
      Throws:
      IOException - if an I/O error occurs
    • history

      public static void history(org.jline.reader.LineReader reader, PrintStream out, PrintStream err, Path currentDir, String[] argv) throws Exception
      Displays or manipulates the command history.
      Parameters:
      reader - the line reader
      out - the output stream
      err - the error stream
      currentDir - the current directory
      argv - command arguments
      Throws:
      Exception - if an error occurs
    • complete

      public static void complete(org.jline.reader.LineReader reader, PrintStream out, PrintStream err, Map<String,List<Completers.CompletionData>> completions, String[] argv) throws Options.HelpException
      Edits command-specific tab completions.
      Parameters:
      reader - the line reader
      out - the output stream
      err - the error stream
      completions - the map of command completions
      argv - command arguments
      Throws:
      Options.HelpException - if help is requested or an error occurs
    • widget

      public static void widget(org.jline.reader.LineReader reader, PrintStream out, PrintStream err, Function<String,org.jline.reader.Widget> widgetCreator, String[] argv) throws Exception
      Manipulates line reader widgets.
      Parameters:
      reader - the line reader
      out - the output stream
      err - the error stream
      widgetCreator - function to create widgets from function names
      argv - command arguments
      Throws:
      Exception - if an error occurs
    • keymap

      public static void keymap(org.jline.reader.LineReader reader, PrintStream out, PrintStream err, String[] argv) throws Options.HelpException
      Manipulates line reader keymaps.
      Parameters:
      reader - the line reader
      out - the output stream
      err - the error stream
      argv - command arguments
      Throws:
      Options.HelpException - if help is requested or an error occurs
    • setopt

      public static void setopt(org.jline.reader.LineReader reader, PrintStream out, PrintStream err, String[] argv) throws Options.HelpException
      Sets line reader options.
      Parameters:
      reader - the line reader
      out - the output stream
      err - the error stream
      argv - command arguments
      Throws:
      Options.HelpException - if help is requested or an error occurs
    • unsetopt

      public static void unsetopt(org.jline.reader.LineReader reader, PrintStream out, PrintStream err, String[] argv) throws Options.HelpException
      Unsets line reader options.
      Parameters:
      reader - the line reader
      out - the output stream
      err - the error stream
      argv - command arguments
      Throws:
      Options.HelpException - if help is requested or an error occurs
    • setvar

      public static void setvar(org.jline.reader.LineReader lineReader, PrintStream out, PrintStream err, String[] argv) throws Options.HelpException
      Sets or displays line reader variables.
      Parameters:
      lineReader - the line reader
      out - the output stream
      err - the error stream
      argv - command arguments
      Throws:
      Options.HelpException - if help is requested or an error occurs
    • colors

      public static void colors(org.jline.terminal.Terminal terminal, PrintStream out, String[] argv) throws Options.HelpException, IOException
      Displays color tables and ANSI styles.
      Parameters:
      terminal - the terminal to use
      out - the output stream
      argv - command arguments
      Throws:
      Options.HelpException - if help is requested or an error occurs
      IOException - if an I/O error occurs
    • highlighter

      public static void highlighter(org.jline.reader.LineReader lineReader, org.jline.terminal.Terminal terminal, PrintStream out, PrintStream err, String[] argv, ConfigurationPath configPath) throws Options.HelpException
      Manages syntax highlighting themes.
      Parameters:
      lineReader - the line reader
      terminal - the terminal to use
      out - the output stream
      err - the error stream
      argv - command arguments
      configPath - the configuration path
      Throws:
      Options.HelpException - if help is requested or an error occurs