Package org.jline.builtins
Class Commands
- java.lang.Object
-
- org.jline.builtins.Commands
-
public class Commands extends java.lang.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 Summary
Constructors Constructor Description Commands()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
colors(org.jline.terminal.Terminal terminal, java.io.PrintStream out, java.lang.String[] argv)
Displays color tables and ANSI styles.static void
complete(org.jline.reader.LineReader reader, java.io.PrintStream out, java.io.PrintStream err, java.util.Map<java.lang.String,java.util.List<Completers.CompletionData>> completions, java.lang.String[] argv)
Edits command-specific tab completions.protected static java.util.List<java.nio.file.Path>
findFiles(java.nio.file.Path root, java.lang.String files)
Finds files matching a glob pattern.static void
highlighter(org.jline.reader.LineReader lineReader, org.jline.terminal.Terminal terminal, java.io.PrintStream out, java.io.PrintStream err, java.lang.String[] argv, ConfigurationPath configPath)
Manages syntax highlighting themes.static void
history(org.jline.reader.LineReader reader, java.io.PrintStream out, java.io.PrintStream err, java.nio.file.Path currentDir, java.lang.String[] argv)
Displays or manipulates the command history.static void
keymap(org.jline.reader.LineReader reader, java.io.PrintStream out, java.io.PrintStream err, java.lang.String[] argv)
Manipulates line reader keymaps.static void
less(org.jline.terminal.Terminal terminal, java.io.InputStream in, java.io.PrintStream out, java.io.PrintStream err, java.nio.file.Path currentDir, java.lang.Object[] argv)
Launches the less pager with the specified arguments.static void
less(org.jline.terminal.Terminal terminal, java.io.InputStream in, java.io.PrintStream out, java.io.PrintStream err, java.nio.file.Path currentDir, java.lang.Object[] argv, ConfigurationPath configPath)
Launches the less pager with the specified arguments.static void
nano(org.jline.terminal.Terminal terminal, java.io.PrintStream out, java.io.PrintStream err, java.nio.file.Path currentDir, java.lang.String[] argv)
Launches the nano text editor with the specified arguments.static void
nano(org.jline.terminal.Terminal terminal, java.io.PrintStream out, java.io.PrintStream err, java.nio.file.Path currentDir, java.lang.String[] argv, ConfigurationPath configPath)
Launches the nano text editor with the specified arguments.static void
setopt(org.jline.reader.LineReader reader, java.io.PrintStream out, java.io.PrintStream err, java.lang.String[] argv)
Sets line reader options.static void
setvar(org.jline.reader.LineReader lineReader, java.io.PrintStream out, java.io.PrintStream err, java.lang.String[] argv)
Sets or displays line reader variables.static void
tmux(org.jline.terminal.Terminal terminal, java.io.PrintStream out, java.io.PrintStream err, java.util.function.Supplier<java.lang.Object> getter, java.util.function.Consumer<java.lang.Object> setter, java.util.function.Consumer<org.jline.terminal.Terminal> runner, java.lang.String[] argv)
Implements a terminal multiplexer similar to tmux.static void
unsetopt(org.jline.reader.LineReader reader, java.io.PrintStream out, java.io.PrintStream err, java.lang.String[] argv)
Unsets line reader options.static void
widget(org.jline.reader.LineReader reader, java.io.PrintStream out, java.io.PrintStream err, java.util.function.Function<java.lang.String,org.jline.reader.Widget> widgetCreator, java.lang.String[] argv)
Manipulates line reader widgets.
-
-
-
Method Detail
-
tmux
public static void tmux(org.jline.terminal.Terminal terminal, java.io.PrintStream out, java.io.PrintStream err, java.util.function.Supplier<java.lang.Object> getter, java.util.function.Consumer<java.lang.Object> setter, java.util.function.Consumer<org.jline.terminal.Terminal> runner, java.lang.String[] argv) throws java.lang.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:
java.lang.Exception
- if an error occurs
-
nano
public static void nano(org.jline.terminal.Terminal terminal, java.io.PrintStream out, java.io.PrintStream err, java.nio.file.Path currentDir, java.lang.String[] argv) throws java.lang.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:
java.lang.Exception
- if an error occurs
-
nano
public static void nano(org.jline.terminal.Terminal terminal, java.io.PrintStream out, java.io.PrintStream err, java.nio.file.Path currentDir, java.lang.String[] argv, ConfigurationPath configPath) throws java.lang.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:
java.lang.Exception
- if an error occurs
-
less
public static void less(org.jline.terminal.Terminal terminal, java.io.InputStream in, java.io.PrintStream out, java.io.PrintStream err, java.nio.file.Path currentDir, java.lang.Object[] argv) throws java.lang.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:
java.lang.Exception
- if an error occurs
-
less
public static void less(org.jline.terminal.Terminal terminal, java.io.InputStream in, java.io.PrintStream out, java.io.PrintStream err, java.nio.file.Path currentDir, java.lang.Object[] argv, ConfigurationPath configPath) throws java.lang.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:
java.lang.Exception
- if an error occurs
-
findFiles
protected static java.util.List<java.nio.file.Path> findFiles(java.nio.file.Path root, java.lang.String files) throws java.io.IOException
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:
java.io.IOException
- if an I/O error occurs
-
history
public static void history(org.jline.reader.LineReader reader, java.io.PrintStream out, java.io.PrintStream err, java.nio.file.Path currentDir, java.lang.String[] argv) throws java.lang.Exception
Displays or manipulates the command history.- Parameters:
reader
- the line readerout
- the output streamerr
- the error streamcurrentDir
- the current directoryargv
- command arguments- Throws:
java.lang.Exception
- if an error occurs
-
complete
public static void complete(org.jline.reader.LineReader reader, java.io.PrintStream out, java.io.PrintStream err, java.util.Map<java.lang.String,java.util.List<Completers.CompletionData>> completions, java.lang.String[] argv) throws Options.HelpException
Edits 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, java.io.PrintStream out, java.io.PrintStream err, java.util.function.Function<java.lang.String,org.jline.reader.Widget> widgetCreator, java.lang.String[] argv) throws java.lang.Exception
Manipulates line reader widgets.- Parameters:
reader
- the line readerout
- the output streamerr
- the error streamwidgetCreator
- function to create widgets from function namesargv
- command arguments- Throws:
java.lang.Exception
- if an error occurs
-
keymap
public static void keymap(org.jline.reader.LineReader reader, java.io.PrintStream out, java.io.PrintStream err, java.lang.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, java.io.PrintStream out, java.io.PrintStream err, java.lang.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, java.io.PrintStream out, java.io.PrintStream err, java.lang.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, java.io.PrintStream out, java.io.PrintStream err, java.lang.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, java.io.PrintStream out, java.lang.String[] argv) throws Options.HelpException, java.io.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 occursjava.io.IOException
- if an I/O error occurs
-
highlighter
public static void highlighter(org.jline.reader.LineReader lineReader, org.jline.terminal.Terminal terminal, java.io.PrintStream out, java.io.PrintStream err, java.lang.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
-
-