Skip to content

Commit

Permalink
Support finding poac.toml in parent directories
Browse files Browse the repository at this point in the history
  • Loading branch information
ken-matsui committed Dec 31, 2023
1 parent 10e3bcd commit 4021983
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion src/Manifest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,28 @@
#define TOML11_NO_ERROR_PREFIX
#include <toml.hpp>

static Path findManifest() {
Path candidate = fs::current_path();
while (true) {
const Path config_path = candidate / "poac.toml";
Logger::debug("Finding manifest: ", config_path);
if (fs::exists(config_path)) {
return config_path;
}

const Path parent_path = candidate.parent_path();
if (candidate.has_parent_path()
&& parent_path != candidate.root_directory()) {
candidate = parent_path;
} else {
break;
}
}

throw std::runtime_error("could not find `poac.toml` here and in its parents"
);
}

class Manifest {
public:
static Manifest& instance() noexcept {
Expand All @@ -32,7 +54,7 @@ class Manifest {
toml::color::disable();
}

data = toml::parse("poac.toml");
data = toml::parse(findManifest());
}

Option<toml::value> data = None;
Expand Down

0 comments on commit 4021983

Please sign in to comment.