mod app;
use clap::{Parser, Subcommand};
use eframe::egui;
#[derive(Parser)]
#[command(version, about)]
struct Cli {
#[command(subcommand)]
command: Option<Command>,
}
#[derive(Subcommand)]
enum Command {
Edit,
Show,
}
fn main() -> eframe::Result {
match Cli::parse().command {
Some(Command::Edit) => {
if let Err(e) = app::run_edit() {
eprintln!("write: {e}");
std::process::exit(1);
}
return Ok(());
}
Some(Command::Show) => {
if let Err(e) = app::run_show() {
eprintln!("write: {e}");
std::process::exit(1);
}
return Ok(());
}
None => {}
}
let (file, seed_words, boot_size) = match app::open_session_file() {
Ok(Some(triple)) => triple,
Ok(None) => {
eprintln!("write: another session already holds today's file; exiting.");
return Ok(());
}
Err(e) => {
eprintln!("write: {e}");
std::process::exit(1);
}
};
let native_options = eframe::NativeOptions {
viewport: egui::ViewportBuilder::default()
.with_titlebar_shown(false)
.with_title_shown(false)
.with_fullsize_content_view(true)
.with_maximized(true),
..Default::default()
};
eframe::run_native(
"write",
native_options,
Box::new(move |cc| {
Ok(Box::new(app::WriteApp::new(
cc, file, seed_words, boot_size,
)))
}),
)
}