135 lines
4.3 KiB
Rust
135 lines
4.3 KiB
Rust
|
|
//! Geolog GUI - Graphical interface for geometric logic
|
||
|
|
//!
|
||
|
|
//! Usage: geolog-gui [workspace]
|
||
|
|
//!
|
||
|
|
//! Provides a graphical interface for:
|
||
|
|
//! - Browsing and editing theories and instances
|
||
|
|
//! - Visualizing chase execution
|
||
|
|
//! - Displaying relation graphs
|
||
|
|
|
||
|
|
use std::path::PathBuf;
|
||
|
|
|
||
|
|
use eframe::egui;
|
||
|
|
|
||
|
|
use geolog::gui::GeologApp;
|
||
|
|
|
||
|
|
const VERSION: &str = env!("CARGO_PKG_VERSION");
|
||
|
|
|
||
|
|
fn main() -> eframe::Result<()> {
|
||
|
|
// Parse command line arguments
|
||
|
|
let args: Vec<String> = std::env::args().skip(1).collect();
|
||
|
|
let (workspace_path, source_files) = parse_args(&args);
|
||
|
|
|
||
|
|
// Set up native window options
|
||
|
|
let options = eframe::NativeOptions {
|
||
|
|
viewport: egui::ViewportBuilder::default()
|
||
|
|
.with_inner_size([1200.0, 800.0])
|
||
|
|
.with_min_inner_size([800.0, 600.0])
|
||
|
|
.with_title(format!("Geolog v{}", VERSION)),
|
||
|
|
..Default::default()
|
||
|
|
};
|
||
|
|
|
||
|
|
// Run the application
|
||
|
|
eframe::run_native(
|
||
|
|
"Geolog",
|
||
|
|
options,
|
||
|
|
Box::new(move |cc| {
|
||
|
|
// Set up custom fonts and styles
|
||
|
|
setup_fonts(&cc.egui_ctx);
|
||
|
|
|
||
|
|
// Create the app
|
||
|
|
let mut app = if let Some(path) = workspace_path {
|
||
|
|
GeologApp::with_path(cc, path)
|
||
|
|
} else {
|
||
|
|
GeologApp::new(cc)
|
||
|
|
};
|
||
|
|
|
||
|
|
// Load source files if provided
|
||
|
|
for path in source_files {
|
||
|
|
app.state.load_file(&path);
|
||
|
|
app.state.execute_editor();
|
||
|
|
}
|
||
|
|
|
||
|
|
Ok(Box::new(app))
|
||
|
|
}),
|
||
|
|
)
|
||
|
|
}
|
||
|
|
|
||
|
|
/// Parse command line arguments
|
||
|
|
fn parse_args(args: &[String]) -> (Option<PathBuf>, Vec<PathBuf>) {
|
||
|
|
let mut workspace_path = None;
|
||
|
|
let mut source_files = Vec::new();
|
||
|
|
let mut i = 0;
|
||
|
|
|
||
|
|
while i < args.len() {
|
||
|
|
let arg = &args[i];
|
||
|
|
match arg.as_str() {
|
||
|
|
"-d" | "--dir" => {
|
||
|
|
if i + 1 < args.len() {
|
||
|
|
workspace_path = Some(PathBuf::from(&args[i + 1]));
|
||
|
|
i += 2;
|
||
|
|
} else {
|
||
|
|
eprintln!("Error: -d requires a path argument");
|
||
|
|
std::process::exit(1);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
"-h" | "--help" => {
|
||
|
|
println!("geolog-gui v{} - Geometric Logic GUI", VERSION);
|
||
|
|
println!();
|
||
|
|
println!("Usage: geolog-gui [OPTIONS] [source_files...]");
|
||
|
|
println!();
|
||
|
|
println!("Options:");
|
||
|
|
println!(" -d, --dir <path> Use <path> as workspace directory for persistence");
|
||
|
|
println!(" -h, --help Show this help message");
|
||
|
|
println!(" -v, --version Show version");
|
||
|
|
println!();
|
||
|
|
println!("Examples:");
|
||
|
|
println!(" geolog-gui Start GUI (in-memory, no persistence)");
|
||
|
|
println!(" geolog-gui -d ./myproject Start GUI with workspace persistence");
|
||
|
|
println!(" geolog-gui file.geolog Load file.geolog on startup");
|
||
|
|
std::process::exit(0);
|
||
|
|
}
|
||
|
|
"-v" | "--version" => {
|
||
|
|
println!("geolog-gui v{}", VERSION);
|
||
|
|
std::process::exit(0);
|
||
|
|
}
|
||
|
|
_ if arg.starts_with('-') => {
|
||
|
|
eprintln!("Error: Unknown option '{}'", arg);
|
||
|
|
eprintln!("Try 'geolog-gui --help' for usage information");
|
||
|
|
std::process::exit(1);
|
||
|
|
}
|
||
|
|
_ => {
|
||
|
|
// Positional argument - treat as source file
|
||
|
|
source_files.push(PathBuf::from(arg));
|
||
|
|
i += 1;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
(workspace_path, source_files)
|
||
|
|
}
|
||
|
|
|
||
|
|
/// Set up custom fonts and styles
|
||
|
|
fn setup_fonts(ctx: &egui::Context) {
|
||
|
|
// Use a slightly larger default font
|
||
|
|
let mut style = (*ctx.style()).clone();
|
||
|
|
style.text_styles.insert(
|
||
|
|
egui::TextStyle::Body,
|
||
|
|
egui::FontId::proportional(14.0),
|
||
|
|
);
|
||
|
|
style.text_styles.insert(
|
||
|
|
egui::TextStyle::Heading,
|
||
|
|
egui::FontId::proportional(18.0),
|
||
|
|
);
|
||
|
|
style.text_styles.insert(
|
||
|
|
egui::TextStyle::Monospace,
|
||
|
|
egui::FontId::monospace(13.0),
|
||
|
|
);
|
||
|
|
|
||
|
|
// Set up dark theme with custom colors
|
||
|
|
style.visuals = egui::Visuals::dark();
|
||
|
|
style.visuals.override_text_color = Some(egui::Color32::from_gray(220));
|
||
|
|
|
||
|
|
ctx.set_style(style);
|
||
|
|
}
|