feat(furdb): add isocline for better command line

This commit is contained in:
2026-08-17 12:14:30 +02:00
parent ed84a65757
commit 1d4e8bb1d0
6 changed files with 23 additions and 8 deletions
+6 -5
View File
@@ -4,16 +4,16 @@ set -e
BUILD_DIR="build" BUILD_DIR="build"
echo "Running clang-format..." FILES=$(git diff --cached --name-only --diff-filter=ACM | grep -E '\.(cpp|hpp)$' | grep -v 'deps/' || true)
FILES=$(git diff --cached --name-only --diff-filter=ACM | grep -E '\.(cpp|hpp)$' || true)
if [ -z "$FILES" ]; then if [ -z "$FILES" ]; then
echo "No C/C++ files to check" echo "No C/C++ files to check"
exit 0 exit 0
fi fi
git diff -U0 --cached | \ echo "Running clang-format..."
git diff -U0 --cached -- $FILES | \
python3 <(curl -s https://raw.githubusercontent.com/llvm/llvm-project/refs/heads/main/clang/tools/clang-format/clang-format-diff.py) -p1 -i python3 <(curl -s https://raw.githubusercontent.com/llvm/llvm-project/refs/heads/main/clang/tools/clang-format/clang-format-diff.py) -p1 -i
echo "Running clang-tidy..." echo "Running clang-tidy..."
@@ -21,7 +21,8 @@ echo "Running clang-tidy..."
for file in $FILES; do for file in $FILES; do
clang-tidy \ clang-tidy \
"$file" \ "$file" \
--header-filter="^(?!.*deps/).*" \
-p "$BUILD_DIR" -p "$BUILD_DIR"
done done
echo "pre-commit checks passed" echo "pre-commit checks passed"
+3
View File
@@ -0,0 +1,3 @@
[submodule "furdb/deps/isocline"]
path = furdb/deps/isocline
url = https://github.com/daanx/isocline
+4 -1
View File
@@ -1,5 +1,8 @@
set(IC_USE_CXX ON)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/deps/isocline)
file(GLOB_RECURSE FURDB_SRCS "src/**.cpp") file(GLOB_RECURSE FURDB_SRCS "src/**.cpp")
file(GLOB_RECURSE FURDB_HDRS "include/**.hpp") file(GLOB_RECURSE FURDB_HDRS "include/**.hpp")
add_executable(furdb ${FURDB_SRCS} ${FURDB_HDRS}) add_executable(furdb ${FURDB_SRCS} ${FURDB_HDRS})
target_include_directories(furdb PRIVATE include/) target_include_directories(furdb PRIVATE include/)
target_link_libraries(furdb PUBLIC furlang libfurc libfurvm) target_link_libraries(furdb PUBLIC furlang libfurc libfurvm isocline)
+1
View File
@@ -0,0 +1 @@
Checks: '-*'
Submodule furdb/deps/isocline added at 8d6dc1ef95
+8 -2
View File
@@ -1,6 +1,7 @@
#include "command.hpp" #include "command.hpp"
#include "context.hpp" #include "context.hpp"
#include "furvm/function.hpp" #include "furvm/function.hpp"
#include "isocline.h"
#include <fstream> #include <fstream>
#include <furvm/fwd.hpp> #include <furvm/fwd.hpp>
@@ -50,6 +51,8 @@ int main(int argc, char** argv) {
s_commands["break"] = s_commands["b"] = new break_command(); s_commands["break"] = s_commands["b"] = new break_command();
s_commands["info"] = s_commands["i"] = new info_command(); s_commands["info"] = s_commands["i"] = new info_command();
ic_set_history(nullptr, -1);
try { try {
std::ifstream file(argv[1], std::ios::binary | std::ios::in); std::ifstream file(argv[1], std::ios::binary | std::ios::in);
@@ -72,8 +75,11 @@ int main(int argc, char** argv) {
std::string prevInput; std::string prevInput;
while (ctx.running) { while (ctx.running) {
std::swap(inputLine, prevInput); std::swap(inputLine, prevInput);
std::cout << "(furdb) ";
if (!std::getline(std::cin, inputLine)) break; char* inputRaw = ic_readline("furdb");
if (inputRaw == nullptr) break;
inputLine = inputRaw;
free(inputRaw); // NOLINT
if (inputLine.empty()) { if (inputLine.empty()) {
inputLine = prevInput; inputLine = prevInput;