mirror of
https://forge.katzen.cafe/schrottkatze/nix-configs.git
synced 2024-11-05 15:16:23 +01:00
jrnl: shorten command and add inquire
This commit is contained in:
parent
caaa7c7c6b
commit
73bbc7c616
|
@ -1,5 +1,5 @@
|
||||||
[package]
|
[package]
|
||||||
name = "jrnl"
|
name = "j"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
|
@ -15,3 +15,4 @@ petgraph = "0.6.4"
|
||||||
ratatui = "0.26.2"
|
ratatui = "0.26.2"
|
||||||
temp-file = "0.1.8"
|
temp-file = "0.1.8"
|
||||||
termsize = "0.1.6"
|
termsize = "0.1.6"
|
||||||
|
inquire = "0.7.5"
|
||||||
|
|
|
@ -6,6 +6,7 @@ use std::{
|
||||||
process::Command,
|
process::Command,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use inquire::Text;
|
||||||
use temp_file::{TempFile, TempFileBuilder};
|
use temp_file::{TempFile, TempFileBuilder};
|
||||||
|
|
||||||
use crate::md::{Entry, ToMd};
|
use crate::md::{Entry, ToMd};
|
||||||
|
@ -17,7 +18,7 @@ pub fn add_entry(path: PathBuf, title: Option<String>) -> io::Result<()> {
|
||||||
std::process::exit(1);
|
std::process::exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
let title = prompt("Title")?;
|
let title = Text::new("Title").prompt().unwrap();
|
||||||
|
|
||||||
let tmp = TempFileBuilder::new()
|
let tmp = TempFileBuilder::new()
|
||||||
.suffix(".jrnl-entry.md")
|
.suffix(".jrnl-entry.md")
|
||||||
|
@ -57,12 +58,3 @@ pub fn add_entry(path: PathBuf, title: Option<String>) -> io::Result<()> {
|
||||||
|
|
||||||
Ok(())
|
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