615fd03e51
Corrige fprintf que usaba %s con std::string sin .c_str(). Actualiza path WSL en el launcher PowerShell a Ubuntu-22.04. Añade repo_url en app.md apuntando al repo en Gitea. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
79 lines
2.1 KiB
C++
79 lines
2.1 KiB
C++
#include "app_base.h"
|
|
#include "imgui.h"
|
|
#include "core/fullscreen_window.h"
|
|
#include "data.h"
|
|
#include "views.h"
|
|
|
|
#include <cstdio>
|
|
#include <cstdlib>
|
|
#include <string>
|
|
#include <fstream>
|
|
|
|
static RegistryData g_data;
|
|
static std::string g_db_path;
|
|
static bool g_loaded = false;
|
|
|
|
static void reload_data() {
|
|
g_data = RegistryData{};
|
|
g_loaded = load_registry_data(g_db_path.c_str(), g_data);
|
|
if (!g_loaded) {
|
|
fprintf(stderr, "Failed to load registry data from: %s\n", g_db_path.c_str());
|
|
}
|
|
}
|
|
|
|
static void render() {
|
|
if (ImGui::GetIO().UserData != nullptr) {
|
|
ImGui::GetIO().UserData = nullptr;
|
|
reload_data();
|
|
}
|
|
|
|
if (!g_loaded) {
|
|
fullscreen_window_begin("##error");
|
|
ImGui::TextColored(ImVec4(1, 0.3f, 0.3f, 1),
|
|
"Could not open registry.db");
|
|
ImGui::Spacing();
|
|
ImGui::Text("Tried: %s", g_db_path.c_str());
|
|
ImGui::Spacing();
|
|
ImGui::TextWrapped("Usage: registry_dashboard <path1> [path2] [path3] ...");
|
|
ImGui::Spacing();
|
|
if (ImGui::Button("Retry")) {
|
|
reload_data();
|
|
}
|
|
fullscreen_window_end();
|
|
return;
|
|
}
|
|
|
|
draw_dashboard(g_data);
|
|
}
|
|
|
|
int main(int argc, char** argv) {
|
|
if (argc < 2) {
|
|
fprintf(stderr, "Usage: registry_dashboard <db_path> [fallback_path ...]\n");
|
|
fprintf(stderr, " Tries each path in order until one opens successfully.\n");
|
|
return 1;
|
|
}
|
|
|
|
// Try each argument in order
|
|
for (int i = 1; i < argc; i++) {
|
|
std::string candidate = argv[i];
|
|
if (std::ifstream(candidate).good()) {
|
|
g_db_path = candidate;
|
|
fprintf(stdout, "Using: %s\n", g_db_path.c_str());
|
|
break;
|
|
}
|
|
fprintf(stderr, "Not found: %s\n", candidate.c_str());
|
|
}
|
|
|
|
if (g_db_path.empty()) {
|
|
// None found, use last arg so error screen shows something useful
|
|
g_db_path = argv[argc - 1];
|
|
}
|
|
|
|
reload_data();
|
|
|
|
return fn::run_app(
|
|
{.title = "fn_registry Dashboard", .width = 1600, .height = 1000, .viewports = true},
|
|
render
|
|
);
|
|
}
|