diff --git a/programs/jrnl/Cargo.toml b/programs/jrnl/Cargo.toml index 12f231a..8e3044a 100644 --- a/programs/jrnl/Cargo.toml +++ b/programs/jrnl/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "jrnl" +name = "j" version = "0.1.0" edition = "2021" @@ -15,3 +15,4 @@ petgraph = "0.6.4" ratatui = "0.26.2" temp-file = "0.1.8" termsize = "0.1.6" +inquire = "0.7.5" diff --git a/programs/jrnl/src/commands/add_entry.rs b/programs/jrnl/src/commands/add_entry.rs index 8dd1b92..c7f78db 100644 --- a/programs/jrnl/src/commands/add_entry.rs +++ b/programs/jrnl/src/commands/add_entry.rs @@ -6,6 +6,7 @@ use std::{ process::Command, }; +use inquire::Text; use temp_file::{TempFile, TempFileBuilder}; use crate::md::{Entry, ToMd}; @@ -17,7 +18,7 @@ pub fn add_entry(path: PathBuf, title: Option) -> io::Result<()> { std::process::exit(1); } - let title = prompt("Title")?; + let title = Text::new("Title").prompt().unwrap(); let tmp = TempFileBuilder::new() .suffix(".jrnl-entry.md") @@ -57,12 +58,3 @@ pub fn add_entry(path: PathBuf, title: Option) -> io::Result<()> { Ok(()) } - -fn prompt(title: &str) -> io::Result { - print!("{}: ", title); - let _ = io::stdout().flush(); - let mut buf = String::new(); - let stdin = io::stdin(); - stdin.read_line(&mut buf)?; - Ok(buf) -}