mirror of
https://github.com/zaphar/sheetsui.git
synced 2025-07-22 13:00:22 -04:00
36 lines
777 B
Rust
36 lines
777 B
Rust
use std::{path::PathBuf, process::ExitCode};
|
|
|
|
use clap::Parser;
|
|
use ratatui;
|
|
use ui::Workspace;
|
|
|
|
mod sheet;
|
|
mod ui;
|
|
|
|
#[derive(Parser, Debug)]
|
|
#[command(version, about, long_about = None)]
|
|
pub struct Args {
|
|
#[arg()]
|
|
workbook: PathBuf,
|
|
}
|
|
|
|
fn run(terminal: &mut ratatui::DefaultTerminal, name: PathBuf) -> anyhow::Result<ExitCode> {
|
|
let mut ws = Workspace::load(&name)?;
|
|
loop {
|
|
terminal.draw(|frame| ui::draw(frame, &mut ws))?;
|
|
if let Some(code) = ws.handle_input()? {
|
|
return Ok(code);
|
|
}
|
|
}
|
|
}
|
|
|
|
fn main() -> anyhow::Result<ExitCode> {
|
|
let args = Args::parse();
|
|
|
|
let mut terminal = ratatui::init();
|
|
terminal.clear()?;
|
|
let app_result = run(&mut terminal, args.workbook);
|
|
ratatui::restore();
|
|
app_result
|
|
}
|