use nanorust::config::Config;
use nanorust::editor::Editor;
use nanorust::Result;
use std::path::Path;
fn main() {
if let Err(e) = run() {
eprintln!("Error: {}", e);
std::process::exit(1);
}
std::process::exit(0);
}
fn run() -> Result<()> {
let (config, filename) = Config::from_args();
let mut editor = Editor::with_config(config)?;
if let Some(file) = filename {
let path = Path::new(&file);
if let Err(e) = editor.open_file(path) {
eprintln!("Warning: Could not open file '{}': {}", file, e);
eprintln!("Starting with empty buffer...");
}
}
editor.run()?;
Ok(())
}