mod app;
mod commands;
mod config;
mod database;
mod draw;
mod editor;
mod events;
mod global;
mod hex;
mod initfile;
mod reader;
mod ruler;
mod text;
mod themes;
mod util;
mod widgets;
use std::process;
use clap::Parser;
use app::App;
#[derive(Parser, Debug)]
#[command(version, about, long_about = None)]
struct Args {
file: String,
#[arg(short, long, default_value = "0")]
offset: String,
#[arg(short, long)]
readonly: bool,
}
fn main() {
let args = Args::parse();
let mut app = App::new();
let cursor_offset = util::parse_offset(&args.offset).unwrap_or_default();
let _ = app.read_initfile();
app.load_file(&args.file, cursor_offset, args.readonly)
.unwrap_or_else(|e| {
eprintln!("{}: {}", args.file, e);
process::exit(1);
});
app.list_state.select_first();
let mut terminal = ratatui::init();
while app.running {
terminal
.draw(|f| draw::draw(f, &mut app))
.expect("failed to draw frame");
events::handle_events(&mut app).expect("unable to read events");
}
ratatui::restore();
}