Skip to content
/ qconsole Public

QConsole is a cross-platform read-eval-print-loop (REPL) library intended to be used by Qt6 applications.

License

Notifications You must be signed in to change notification settings

T-V-J/qconsole

Repository files navigation

QConsole

QConsole is a high-level C++17 REPL library for Qt6 console applications with support for Linux, MacOS, and Windows. It features syntax-highlighting, history, unicode, default commands (help, version, exit, etc...), native keybindings, hints, password input, auto-complete, and colorization.

Usage

Here is a simple demonstration:

QConsole console;
console.addDefaultCommands();
console.setHistoryFilePath("history.txt");
console.setDefaultPrompt(QConsole::colorize(">> ", QConsole::Color::Red, QConsole::Style::Bold));

console.addCommand({
  "hello-world",
  "Print 'Hello, world!' and the arguments given to the command.",
  [&](const QConsole::Context& ctx) {
      console.ostream() << "Hello, World! Args: " << ctx.arguments << Qt::endl;
  },
});

console.start();

See the simple example for the above and the complex example for a more involved application. There is also the widget-example demonstrating the usage of a QConsole alongside a QGuiApplication or QApplication.

Do not use asynchronous code to output messages with this library. Instead, wrap your signals with QEventLoop (like in the complex example) or use QFuture to make your asynchronous methods or functions synchronous.

Dependencies

The following libraries should be found on your system:

The following libraries will be automatically downloaded by CMake:

Installation

You can install this library by running the following commands:

git clone https://github.com/le0d4v1nc1/qconsole
cd qconsole
cmake -S . -B build --target install --config Release

Or to include it in your own CMake project:

include(FetchContent)
fetchcontent_declare(qconsole GIT_REPOSITORY https://github.com/le0d4v1nc1/qconsole/ GIT_TAG 2.0.3)
fetchcontent_makeavailable(qconsole)

Contributions

This project accepts pull-requests, bug-reports, and/or feature-requests; see CONTRIBUTING.

License

This project is available under the MIT license.

About

QConsole is a cross-platform read-eval-print-loop (REPL) library intended to be used by Qt6 applications.

Resources

License

Stars

Watchers

Forks

Packages

No packages published