diff --git a/.githooks/pre-commit b/.githooks/pre-commit index b328071..48fc8a5 100755 --- a/.githooks/pre-commit +++ b/.githooks/pre-commit @@ -4,16 +4,16 @@ set -e BUILD_DIR="build" -echo "Running clang-format..." - -FILES=$(git diff --cached --name-only --diff-filter=ACM | grep -E '\.(cpp|hpp)$' || true) +FILES=$(git diff --cached --name-only --diff-filter=ACM | grep -E '\.(cpp|hpp)$' | grep -v 'deps/' || true) if [ -z "$FILES" ]; then echo "No C/C++ files to check" exit 0 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 echo "Running clang-tidy..." @@ -21,7 +21,8 @@ echo "Running clang-tidy..." for file in $FILES; do clang-tidy \ "$file" \ + --header-filter="^(?!.*deps/).*" \ -p "$BUILD_DIR" done -echo "pre-commit checks passed" \ No newline at end of file +echo "pre-commit checks passed" diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..df52ac6 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "furdb/deps/isocline"] + path = furdb/deps/isocline + url = https://github.com/daanx/isocline diff --git a/furdb/CMakeLists.txt b/furdb/CMakeLists.txt index f26f5a5..44771f2 100644 --- a/furdb/CMakeLists.txt +++ b/furdb/CMakeLists.txt @@ -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_HDRS "include/**.hpp") add_executable(furdb ${FURDB_SRCS} ${FURDB_HDRS}) target_include_directories(furdb PRIVATE include/) -target_link_libraries(furdb PUBLIC furlang libfurc libfurvm) +target_link_libraries(furdb PUBLIC furlang libfurc libfurvm isocline) diff --git a/furdb/deps/.clang-tidy b/furdb/deps/.clang-tidy new file mode 100644 index 0000000..612bd0e --- /dev/null +++ b/furdb/deps/.clang-tidy @@ -0,0 +1 @@ +Checks: '-*' diff --git a/furdb/deps/isocline b/furdb/deps/isocline new file mode 160000 index 0000000..8d6dc1e --- /dev/null +++ b/furdb/deps/isocline @@ -0,0 +1 @@ +Subproject commit 8d6dc1ef95b1b46711e66eb23d39d4467a0fcdac diff --git a/furdb/src/main.cpp b/furdb/src/main.cpp index 3a96b35..cd4f83a 100644 --- a/furdb/src/main.cpp +++ b/furdb/src/main.cpp @@ -1,6 +1,7 @@ #include "command.hpp" #include "context.hpp" #include "furvm/function.hpp" +#include "isocline.h" #include #include @@ -50,6 +51,8 @@ int main(int argc, char** argv) { s_commands["break"] = s_commands["b"] = new break_command(); s_commands["info"] = s_commands["i"] = new info_command(); + ic_set_history(nullptr, -1); + try { std::ifstream file(argv[1], std::ios::binary | std::ios::in); @@ -72,8 +75,11 @@ int main(int argc, char** argv) { std::string prevInput; while (ctx.running) { 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()) { inputLine = prevInput;