add header to a note with title, author and date
This commit is contained in:
parent
3b30f116cc
commit
4914007165
@ -155,8 +155,18 @@ pub fn create(header: &str, category: &str) -> Result<()> {
|
|||||||
create_dir(category)?;
|
create_dir(category)?;
|
||||||
is_duplicate(header, category)?;
|
is_duplicate(header, category)?;
|
||||||
let mut f = fs::File::create(&file)?;
|
let mut f = fs::File::create(&file)?;
|
||||||
|
let username = env::var("USER").unwrap_or("".to_owned());
|
||||||
|
let date = Utc::now().format("%d-%m-%Y");
|
||||||
|
let note_header = format!(
|
||||||
|
r#"---
|
||||||
|
title: {}
|
||||||
|
author: {}
|
||||||
|
date: {}
|
||||||
|
---"#,
|
||||||
|
header, username, date
|
||||||
|
);
|
||||||
f.set_permissions(fs::Permissions::from_mode(0o600))?;
|
f.set_permissions(fs::Permissions::from_mode(0o600))?;
|
||||||
f.write(format!("# {}\n", header).as_bytes())?;
|
f.write(format!("{}\n", note_header).as_bytes())?;
|
||||||
Command::new(editor).arg(&file).status()?;
|
Command::new(editor).arg(&file).status()?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user