Package org.jline.builtins
Class Commands
java.lang.Object
org.jline.builtins.Commands
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
colors
(org.jline.terminal.Terminal terminal, PrintStream out, String[] argv) Displays color tables and ANSI styles.static void
complete
(org.jline.reader.LineReader reader, PrintStream out, PrintStream err, Map<String, List<Completers.CompletionData>> completions, String[] argv) Edits command-specific tab completions.Finds files matching a glob pattern.static void
highlighter
(org.jline.reader.LineReader lineReader, org.jline.terminal.Terminal terminal, PrintStream out, PrintStream err, String[] argv, ConfigurationPath configPath) Manages syntax highlighting themes.static void
history
(org.jline.reader.LineReader reader, PrintStream out, PrintStream err, Path currentDir, String[] argv) Displays or manipulates the command history.static void
keymap
(org.jline.reader.LineReader reader, PrintStream out, PrintStream err, String[] argv) Manipulates line reader keymaps.static void
less
(org.jline.terminal.Terminal terminal, InputStream in, PrintStream out, PrintStream err, Path currentDir, Object[] argv) Launches the less pager with the specified arguments.static void
less
(org.jline.terminal.Terminal terminal, InputStream in, PrintStream out, PrintStream err, Path currentDir, Object[] argv, ConfigurationPath configPath) Launches the less pager with the specified arguments.static void
nano
(org.jline.terminal.Terminal terminal, PrintStream out, PrintStream err, Path currentDir, String[] argv) Launches the nano text editor with the specified arguments.static void
nano
(org.jline.terminal.Terminal terminal, PrintStream out, PrintStream err, Path currentDir, String[] argv, ConfigurationPath configPath) Launches the nano text editor with the specified arguments.static void
setopt
(org.jline.reader.LineReader reader, PrintStream out, PrintStream err, String[] argv) Sets line reader options.static void
setvar
(org.jline.reader.LineReader lineReader, PrintStream out, PrintStream err, String[] argv) Sets or displays line reader variables.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) Implements a terminal multiplexer similar to tmux.static void
unsetopt
(org.jline.reader.LineReader reader, PrintStream out, PrintStream err, String[] argv) Unsets line reader options.static void
widget
(org.jline.reader.LineReader reader, PrintStream out, PrintStream err, Function<String, org.jline.reader.Widget> widgetCreator, String[] argv) Manipulates line reader widgets.
-
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 useout
- the output streamerr
- the error streamgetter
- supplier to get the current tmux instancesetter
- consumer to set the current tmux instancerunner
- consumer to run a terminalargv
- 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 callsnano(Terminal, PrintStream, PrintStream, Path, String[], ConfigurationPath)
with a null ConfigurationPath.- Parameters:
terminal
- the terminal to useout
- the output streamerr
- the error streamcurrentDir
- the current directoryargv
- 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 useout
- the output streamerr
- the error streamcurrentDir
- the current directoryargv
- command argumentsconfigPath
- 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 callsless(Terminal, InputStream, PrintStream, PrintStream, Path, Object[], ConfigurationPath)
with a null ConfigurationPath.- Parameters:
terminal
- the terminal to usein
- the input streamout
- the output streamerr
- the error streamcurrentDir
- the current directoryargv
- 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 usein
- the input streamout
- the output streamerr
- the error streamcurrentDir
- the current directoryargv
- command arguments (can be String or Source objects)configPath
- the configuration path or null for default- Throws:
Exception
- if an error occurs
-
findFiles
Finds files matching a glob pattern.- Parameters:
root
- the root directory to search fromfiles
- 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 readerout
- the output streamerr
- the error streamcurrentDir
- the current directoryargv
- 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.HelpExceptionEdits command-specific tab completions.- Parameters:
reader
- the line readerout
- the output streamerr
- the error streamcompletions
- the map of command completionsargv
- 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 ExceptionManipulates line reader widgets.- Parameters:
reader
- the line readerout
- the output streamerr
- the error streamwidgetCreator
- function to create widgets from function namesargv
- 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 readerout
- the output streamerr
- the error streamargv
- 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 readerout
- the output streamerr
- the error streamargv
- 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 readerout
- the output streamerr
- the error streamargv
- 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 readerout
- the output streamerr
- the error streamargv
- 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 useout
- the output streamargv
- command arguments- Throws:
Options.HelpException
- if help is requested or an error occursIOException
- 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 readerterminal
- the terminal to useout
- the output streamerr
- the error streamargv
- command argumentsconfigPath
- the configuration path- Throws:
Options.HelpException
- if help is requested or an error occurs
-