check for EDITOR variable

This commit is contained in:
Volodymyr Patuta 2020-11-27 22:34:13 +01:00
parent 01fb829510
commit 6a182b7bbc
1 changed files with 14 additions and 0 deletions

View File

@ -1,10 +1,24 @@
use anyhow::Result; use anyhow::Result;
use dialoguer::{theme::ColorfulTheme, Input};
use rnote::{app, process}; use rnote::{app, process};
mod rnote; mod rnote;
fn check() -> Result<()> {
let editor = std::env::var("EDITOR").unwrap_or("".to_owned());
if editor.is_empty() {
let editor: String = Input::with_theme(&ColorfulTheme::default())
.with_prompt("Your text editor")
.interact_text()?;
std::env::set_var("EDITOR", editor);
}
Ok(())
}
fn main() -> Result<()> { fn main() -> Result<()> {
let mut app = app::make_app(); let mut app = app::make_app();
check()?;
match rnote::app::make_app().get_matches().subcommand() { match rnote::app::make_app().get_matches().subcommand() {
("new", Some(m)) => process::new(m)?, ("new", Some(m)) => process::new(m)?,