public class Console extends Object implements Closeable
Modifier and Type | Field and Description |
---|---|
protected jline.console.ConsoleReader |
console |
protected Logger |
log |
protected CliSession |
session |
Constructor and Description |
---|
Console(Database db,
InputStream input,
OutputStream output)
Simplified constructor for
SessionMode.CORE_API mode. |
Console(KVDatabase kvdb,
Database db,
Permazen jdb,
InputStream input,
OutputStream output,
jline.Terminal terminal,
String encoding,
String appName)
Generic constructor.
|
Console(KVDatabase kvdb,
InputStream input,
OutputStream output)
Simplified constructor for
SessionMode.KEY_VALUE mode. |
Console(Permazen jdb,
InputStream input,
OutputStream output)
Simplified constructor for
SessionMode.PERMAZEN mode. |
Modifier and Type | Method and Description |
---|---|
void |
close() |
jline.console.ConsoleReader |
getConsoleReader()
Get the associated JLine
ConsoleReader . |
CliSession |
getSession()
Get the associated
CliSession . |
static jline.Terminal |
getTerminal()
Get the
Terminal instance appropriate for this operating system. |
List<CliSession.Action> |
parseCommand(String text)
Parse the given command(s).
|
boolean |
run()
Run this instance.
|
boolean |
runNonInteractive(Reader input,
String inputDescription)
Run this instance in non-interactive (or "batch") mode on the given input.
|
void |
setHistoryFile(File historyFile)
Set/update the command history file.
|
void |
setPassword(String password)
Set a password that must be entered when
run() is invoked. |
protected final Logger log
protected final jline.console.ConsoleReader console
protected final CliSession session
public Console(KVDatabase kvdb, InputStream input, OutputStream output) throws IOException
SessionMode.KEY_VALUE
mode.kvdb
- key/value KVDatabase
input
- console inputoutput
- console outputIOException
- if an I/O error occurspublic Console(Database db, InputStream input, OutputStream output) throws IOException
SessionMode.CORE_API
mode.db
- core API Database
input
- console inputoutput
- console outputIOException
- if an I/O error occurspublic Console(Permazen jdb, InputStream input, OutputStream output) throws IOException
SessionMode.PERMAZEN
mode.jdb
- Permazen
databaseinput
- console inputoutput
- console outputIOException
- if an I/O error occurspublic Console(KVDatabase kvdb, Database db, Permazen jdb, InputStream input, OutputStream output, jline.Terminal terminal, String encoding, String appName) throws IOException
kvdb
- KVDatabase
for SessionMode.KEY_VALUE
(otherwise must be null)db
- Database
for SessionMode.CORE_API
(otherwise must be null)jdb
- Permazen
for SessionMode.PERMAZEN
(otherwise must be null)input
- console inputoutput
- console outputterminal
- JLine terminal interface, or null for defaultencoding
- character encoding for terminal
, or null for defaultappName
- JLine application name, or null for noneIOException
- if an I/O error occursIllegalArgumentException
- if not exactly one of kvdb
, db
or jdb
is not nullpublic jline.console.ConsoleReader getConsoleReader()
ConsoleReader
.public CliSession getSession()
CliSession
.public void setPassword(String password)
run()
is invoked.
Default is no password.
password
- required password, or null for nonepublic void setHistoryFile(File historyFile) throws IOException
historyFile
- file for storing command historyIOException
- if historyFile
cannot be readIllegalArgumentException
- if historyFile
is nullpublic boolean runNonInteractive(Reader input, String inputDescription) throws IOException
input
- command input; is not closed by this methodinputDescription
- description of input (e.g., file name) used for error reporting, or null for noneIOException
- if an I/O error occurspublic boolean run() throws IOException
IOException
- if an I/O error occurspublic List<CliSession.Action> parseCommand(String text)
text
- command inputParseException
- if text
cannot be parsedIllegalArgumentException
- if text
is nullpublic static jline.Terminal getTerminal() throws IOException
Terminal
instance appropriate for this operating system.Terminal
to useIOException
- if an I/O error occurspublic void close()
close
in interface Closeable
close
in interface AutoCloseable
Copyright © 2022. All rights reserved.