use crate::{
    database::{Database, SqliteAsyncHandle},
    note::Note,
    print::format_two_tokens,
};

pub(crate) async fn exec(
    title: &String,
    db: SqliteAsyncHandle,

    is_tag: bool,
) -> Result<String, anyhow::Error> {
    let note = Note::init(title.clone(), is_tag);

    db.lock().await.save(&note).await?;
    note.persist()?;

    Ok(format_two_tokens("note created", &format!("{:?}", note)))
    // Err(anyhow::anyhow!("baby futter"))
}
