c365b1bc43
Modulo nuevo que gestiona el sistema de proyectos del issue 0006. Cada proyecto vive como subcarpeta junto al exe con su operations.db, types.yaml y graph_explorer.db propios. Helpers: - project_validate_slug / project_paths / project_list / project_exists - project_create — bootstrap operations.db con DDL completo (entities, relations, fts5, triggers, assertions, executions, logs) + types.yaml semilla (copia de examples/types.yaml o embed si no existe). - projects_migrate_legacy_layout — mueve operations.db / graph_explorer.db del cwd a projects/default/ si el directorio projects/ no existe. - project_settings_load/save/touch — graph_explorer.ini con last_active y recent (max 5). - project_reveal_in_explorer — Windows ShellExecute / Linux xdg-open. CMakeLists registra project_manager.cpp en add_imgui_app. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
84 lines
3.0 KiB
C++
84 lines
3.0 KiB
C++
#pragma once
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
// Sistema de proyectos: cada proyecto es una subcarpeta junto al exe que
|
|
// contiene sus propios `operations.db`, `types.yaml` y `graph_explorer.db`
|
|
// (layouts). El usuario crea proyectos, los nombra y conmuta entre ellos.
|
|
//
|
|
// Layout en disco:
|
|
//
|
|
// <exe_dir>/
|
|
// graph_explorer.ini # last_active + recent (gestionado aqui)
|
|
// projects/
|
|
// default/
|
|
// operations.db # bootstrap con DDL completo
|
|
// types.yaml # copia editable; semilla = ./examples/types.yaml o embed
|
|
// graph_explorer.db # layouts del proyecto
|
|
// caso_X/
|
|
// ...
|
|
|
|
namespace ge {
|
|
|
|
constexpr const char* k_projects_dir = "projects";
|
|
constexpr const char* k_default_project = "default";
|
|
constexpr const char* k_settings_file = "graph_explorer.ini";
|
|
|
|
struct ProjectPaths {
|
|
std::string root_dir; // <exe>/projects/<slug>/
|
|
std::string operations_db; // <root>/operations.db
|
|
std::string types_yaml; // <root>/types.yaml
|
|
std::string layout_db; // <root>/graph_explorer.db
|
|
};
|
|
|
|
// Valida slug (a-z, 0-9, _ y -). Devuelve true si es valido. error_msg
|
|
// describe el motivo del fallo.
|
|
bool project_validate_slug(const char* name, std::string* error_msg);
|
|
|
|
// Devuelve los paths del proyecto `slug`. NO comprueba existencia en disco.
|
|
ProjectPaths project_paths(const char* slug);
|
|
|
|
// Asegura que `<exe>/projects/` existe. Idempotente.
|
|
bool projects_root_ensure();
|
|
|
|
// Lista proyectos detectados (subdirs de `<exe>/projects/`). Ordenado alfa.
|
|
// Cada string es el slug (basename de la subcarpeta).
|
|
bool project_list(std::vector<std::string>* out);
|
|
|
|
// Devuelve true si la carpeta del proyecto existe y contiene operations.db.
|
|
bool project_exists(const char* slug);
|
|
|
|
// Crea el proyecto `slug`:
|
|
// - mkdir <exe>/projects/<slug>/
|
|
// - bootstrap operations.db con el DDL completo (entities, relations, fts, ...)
|
|
// - escribe types.yaml semilla (basado en examples/types.yaml o embed)
|
|
// Devuelve false y rellena `error_msg` si falla.
|
|
bool project_create(const char* slug, std::string* error_msg);
|
|
|
|
// Migracion: si `<exe>/projects/` no existe pero hay operations.db en el cwd,
|
|
// crea projects/default/ y mueve operations.db + graph_explorer.db ahi.
|
|
// Idempotente: no-op si projects/ ya existe.
|
|
bool projects_migrate_legacy_layout();
|
|
|
|
// Lee/escribe `graph_explorer.ini` (junto al exe). Formato:
|
|
// last_active = <slug>
|
|
// recent = slug1,slug2,slug3
|
|
struct ProjectSettings {
|
|
std::string last_active; // slug del ultimo proyecto abierto
|
|
std::vector<std::string> recent; // mas reciente primero, max 5
|
|
};
|
|
|
|
bool project_settings_load(ProjectSettings* out);
|
|
bool project_settings_save(const ProjectSettings& s);
|
|
|
|
// Marca `slug` como activo y lo empuja al frente de `recent`. Persiste en
|
|
// disco. No-op si slug es vacio.
|
|
void project_settings_touch(const char* slug);
|
|
|
|
// Abre la carpeta del proyecto en el explorador del sistema.
|
|
// (Windows: explorer.exe; Linux: xdg-open).
|
|
void project_reveal_in_explorer(const char* slug);
|
|
|
|
} // namespace ge
|