From 16693493e2d5d31cfd1970465d1b1281cbd6aafb Mon Sep 17 00:00:00 2001 From: peplxx <91543105+peplxx@users.noreply.github.com> Date: Sun, 8 Mar 2026 00:36:12 +0300 Subject: [PATCH 1/5] chore: bump version 0.2.0 -> 0.2.1 --- CMakeLists.txt | 2 +- pyproject.toml | 2 +- uv.lock | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4d4ea89..ccc81e1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.16) project(bldd - VERSION 0.2.0 + VERSION 0.2.1 DESCRIPTION "Backward ldd - Find executables using shared libraries" LANGUAGES CXX ) diff --git a/pyproject.toml b/pyproject.toml index cd51a0b..4fc8ec8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "bldd" -version = "0.2.0" +version = "0.2.1" description = "" readme = "" requires-python = ">=3.14" diff --git a/uv.lock b/uv.lock index 2529d10..5167d51 100644 --- a/uv.lock +++ b/uv.lock @@ -4,7 +4,7 @@ requires-python = ">=3.14" [[package]] name = "bldd" -version = "0.1.0" +version = "0.2.1" source = { virtual = "." } [package.dev-dependencies] From 87ab5f7464b0237f6ab6a3c1a871e35f78529516 Mon Sep 17 00:00:00 2001 From: peplxx <91543105+peplxx@users.noreply.github.com> Date: Sun, 8 Mar 2026 00:37:09 +0300 Subject: [PATCH 2/5] feat: parsing default path config file --- include/bldd/config.h | 10 +++++++++- src/cmd/cli.cpp | 20 +++++++++++++++++--- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/include/bldd/config.h b/include/bldd/config.h index 9e10fa1..8ef1c16 100644 --- a/include/bldd/config.h +++ b/include/bldd/config.h @@ -2,8 +2,10 @@ #include "bldd/types.h" #include +#include #include #include +#include #include namespace bldd { @@ -26,12 +28,18 @@ struct Config { bool recursive = true; Config() - : scan_directories({ "/usr/bin", "/usr/local/bin" }) + : scan_directories({}) , output_format(OutputFormat::TXT) { } static Config load_from_file(std::string const& config_path); + static constexpr std::string_view kDefaultConfigPath = ".config/bldd/bldd.conf"; + static std::filesystem::path get_default_path() + { + char const* home = getenv("HOME"); + return home ? std::filesystem::path(home) / kDefaultConfigPath : std::filesystem::path {}; + } }; inline Config::OutputFormat format_from_string(std::string const&) diff --git a/src/cmd/cli.cpp b/src/cmd/cli.cpp index 5f6db87..474f523 100644 --- a/src/cmd/cli.cpp +++ b/src/cmd/cli.cpp @@ -1,11 +1,13 @@ #include "cli.h" +#include "bldd/config.h" +#include #include namespace bldd::cmd { namespace { -constexpr auto kVersion = "0.2.0"; +constexpr auto kVersion = "0.2.1"; constexpr auto kDescription = "Backward LDD - Find all executable files that use specified shared libraries.\n" "This tool scans directories for ELF executables and reports which executables\n" @@ -105,6 +107,13 @@ Config Cli::build_config() const { Config config; + auto default_path = Config::get_default_path(); + if (!default_path.empty() && std::filesystem::exists(default_path)) { + std::cerr << "Loading configuration from default path: " + << default_path << "\n"; + config = Config::load_from_file(default_path.string()); + } + // Load from config file if specified auto config_path = program_.get("--config"); if (!config_path.empty()) { @@ -121,8 +130,13 @@ Config Cli::build_config() const config.library_filters = program_.get>("--library"); config.output_file = program_.get("--output"); config.output_format = format_from_string(program_.get("--format")); - config.verbose = program_.get("--verbose"); - config.recursive = !program_.get("--no-recursive"); + + // Parse explicit flags + if (program_.get("--verbose")) + config.verbose = program_.get("--verbose"); + + if (!program_.get("--no-recursive")) + config.recursive = !program_.get("--no-recursive"); // Parse architecture filter auto arch_str = program_.get("--arch"); From 69061e0366f0dcd4bc7ba59f21471686ceb3232f Mon Sep 17 00:00:00 2001 From: peplxx <91543105+peplxx@users.noreply.github.com> Date: Sun, 8 Mar 2026 00:38:39 +0300 Subject: [PATCH 3/5] docs: update readme config section --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index d9f387f..f553a51 100644 --- a/README.md +++ b/README.md @@ -86,6 +86,9 @@ bldd -d /opt --no-recursive BLDD supports [configuration files](./config/bldd.conf.example) for persistent settings. +By default, BLDD looks for a configuration file at `~/.config/bldd/bldd.conf`. +You can override this with the `--config` flag. + ## Testing BLDD includes unit and end-to-end tests: From 69fe44edb7129859a4487a2aecf9e9ddc84064ed Mon Sep 17 00:00:00 2001 From: peplxx <91543105+peplxx@users.noreply.github.com> Date: Sun, 8 Mar 2026 00:49:16 +0300 Subject: [PATCH 4/5] fix: tests --- tests/test_config.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/tests/test_config.cpp b/tests/test_config.cpp index 6af58d4..4d47b8e 100644 --- a/tests/test_config.cpp +++ b/tests/test_config.cpp @@ -38,9 +38,7 @@ TEST_CASE("Config default values", "[config]") { bldd::Config config; - REQUIRE(config.scan_directories.size() == 2); - REQUIRE(config.scan_directories[0] == "/usr/bin"); - REQUIRE(config.scan_directories[1] == "/usr/local/bin"); + REQUIRE(config.scan_directories.size() == 0); REQUIRE(config.library_filters.empty()); REQUIRE_FALSE(config.arch_filter.has_value()); REQUIRE(config.output_format == Config::OutputFormat::TXT); @@ -54,7 +52,7 @@ TEST_CASE("Config load from nonexistent file", "[config]") auto config = bldd::Config::load_from_file("/nonexistent/path/config.conf"); // Should return default config - REQUIRE(config.scan_directories.size() == 2); + REQUIRE(config.scan_directories.size() == 0); REQUIRE(config.output_format == Config::OutputFormat::TXT); } @@ -87,7 +85,7 @@ TEST_CASE("Config parsing edge cases", "[config]") auto config = bldd::Config::load_from_file(file.path()); // Should return default config - REQUIRE(config.scan_directories.size() == 2); + REQUIRE(config.scan_directories.size() == 0); } SECTION("Only comments") @@ -100,7 +98,7 @@ TEST_CASE("Config parsing edge cases", "[config]") auto config = bldd::Config::load_from_file(file.path()); - REQUIRE(config.scan_directories.size() == 2); + REQUIRE(config.scan_directories.size() == 0); } SECTION("Whitespace handling") From c145282f17c36e331da088a06a3675b16af69762 Mon Sep 17 00:00:00 2001 From: peplxx <91543105+peplxx@users.noreply.github.com> Date: Sun, 8 Mar 2026 00:55:16 +0300 Subject: [PATCH 5/5] feat: add e2e test for default config read --- scripts/run-e2e.sh | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/scripts/run-e2e.sh b/scripts/run-e2e.sh index 7ddb7e9..7da272b 100755 --- a/scripts/run-e2e.sh +++ b/scripts/run-e2e.sh @@ -156,6 +156,43 @@ if [[ "$PLATFORM" == "macos" ]]; then fi fi +# Config file test +echo "" +echo "--- Test: default-config-loading ---" +# Create default config directory and copy example config +DEFAULT_CONFIG_DIR="$HOME/.config/bldd" +DEFAULT_CONFIG_PATH="$DEFAULT_CONFIG_DIR/bldd.conf" + +# Backup existing config if present +if [[ -f "$DEFAULT_CONFIG_PATH" ]]; then + mv "$DEFAULT_CONFIG_PATH" "$DEFAULT_CONFIG_PATH.backup" + RESTORE_CONFIG=true +else + RESTORE_CONFIG=false +fi + +# Setup test config +mkdir -p "$DEFAULT_CONFIG_DIR" +cp "$WORKDIR/config/bldd.conf.example" "$DEFAULT_CONFIG_PATH" + +# Run bldd and check for config loading message +OUTPUT=$($BLDD 2>&1) || true +echo "$OUTPUT" + +# Cleanup +rm -f "$DEFAULT_CONFIG_PATH" +if [[ "$RESTORE_CONFIG" == "true" ]]; then + mv "$DEFAULT_CONFIG_PATH.backup" "$DEFAULT_CONFIG_PATH" +fi + +# Check result +if echo "$OUTPUT" | grep -q "Loading configuration from default path.*bldd.conf"; then + echo "✓ PASSED: default-config-loading" +else + echo "✗ FAILED: default-config-loading (expected config loading message)" + exit 1 +fi + # No results case echo "" echo "--- Test: no-results ---"