From 6a182b7bbc8db8eada271b21dc333193823d2d0c Mon Sep 17 00:00:00 2001 From: Volodymyr Patuta <6977238-fiplox@users.noreply.gitlab.com> Date: Fri, 27 Nov 2020 22:34:13 +0100 Subject: [PATCH] check for EDITOR variable --- src/main.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/main.rs b/src/main.rs index 04a607e..bdfcc73 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,10 +1,24 @@ use anyhow::Result; +use dialoguer::{theme::ColorfulTheme, Input}; use rnote::{app, process}; 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<()> { let mut app = app::make_app(); + check()?; match rnote::app::make_app().get_matches().subcommand() { ("new", Some(m)) => process::new(m)?,