mirror of
https://forge.katzen.cafe/schrottkatze/nix-configs.git
synced 2024-12-22 09:35:50 +01:00
jrnl: shorten command and add inquire
This commit is contained in:
parent
caaa7c7c6b
commit
73bbc7c616
2 changed files with 4 additions and 11 deletions
|
@ -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"
|
||||
|
|
|
@ -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<String>) -> 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<String>) -> io::Result<()> {
|
|||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn prompt(title: &str) -> io::Result<String> {
|
||||
print!("{}: ", title);
|
||||
let _ = io::stdout().flush();
|
||||
let mut buf = String::new();
|
||||
let stdin = io::stdin();
|
||||
stdin.read_line(&mut buf)?;
|
||||
Ok(buf)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue