2026-10-25 07:20:01 +01:00
|
|
|
// detz entry point: parse the command line and hand it to the glue (docs/glue.md).
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
#include <climits>
|
2026-10-24 07:02:48 +02:00
|
|
|
#include <string>
|
2026-10-25 07:20:01 +01:00
|
|
|
#include "cli/cli.h"
|
|
|
|
|
#include "glue/glue_app.h"
|
|
|
|
|
#include "version.hpp"
|
|
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
std::string running_binary(const char* argv0) {
|
|
|
|
|
char buf[PATH_MAX];
|
|
|
|
|
ssize_t n = readlink("/proc/self/exe", buf, sizeof buf - 1);
|
|
|
|
|
if (n > 0) return std::string(buf, static_cast<size_t>(n));
|
|
|
|
|
return argv0 ? argv0 : "detz";
|
|
|
|
|
}
|
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
|
|
int main(int argc, char** argv) {
|
|
|
|
|
detz::cli::Parser parser;
|
|
|
|
|
detz::cli::Options options = parser.parseOpts(argc, argv);
|
|
|
|
|
detz::glue::GlueApp app(options, std::string(detz::kVersion), running_binary(argc > 0 ? argv[0] : nullptr));
|
|
|
|
|
return app.run();
|
2026-10-24 07:02:48 +02:00
|
|
|
}
|