#!/usr/bin/env python3
"""
This script generates a new note
"""

import calendar
import datetime
import os
from pathlib import Path
import subprocess

from syspath import get_git_root


EDITOR = os.environ.get('EDITOR', 'vim')


def generate_note() -> Path:
    current_time = datetime.datetime.utcnow()

    note_filename = current_time.strftime('%Y%m%d-%H%M.md')
    note_path = get_git_root() / 'app' / 'notes' / note_filename

    timestamp = calendar.timegm(current_time.utctimetuple())
    note = "title\n\nslug\n\n%s\n\nnote\n" % timestamp

    with open(note_path, 'w') as note_handle:
        note_handle.write(note)
    return note_path


def edit_note(note_path: Path) -> None:
    subprocess.call([EDITOR, str(note_path)])


if __name__ == '__main__':
    note_path = generate_note()
    print('Note template written to %s' % note_path)
    edit_note(note_path)

@@ -20,49 +20,23 @@
 on3%0A
-%22%22%22%0AThis script generates a new note%0A%22%22%22%0A
+import argparse
 %0Aimp
@@ -116,16 +116,50 @@
 bprocess
+%0Afrom typing import Optional, cast
 %0A%0Afrom s
@@ -191,127 +191,668 @@
 t%0A%0A%0A
-EDITOR = os.environ.get('EDITOR', 'vim')%0A%0A%0Adef generate_note() -%3E Path:%0A    current_time = datetime.datetime.utcnow()%0A%0A
+DESCRIPTION = %22This script generates a new note or reference%22%0AEDITOR = os.environ.get('EDITOR', 'vim')%0A%0A%0Adef get_reference_slug() -%3E Optional%5Bstr%5D:%0A    parser = argparse.ArgumentParser(description=DESCRIPTION)%0A    parser.add_argument('reference_slug', nargs='?', type=str)%0A    params = parser.parse_args()%0A    reference_slug = cast(Optional%5Bstr%5D, params.reference_slug)%0A    return reference_slug%0A%0A%0Adef generate_note(reference_name: Optional%5Bstr%5D) -%3E Path:%0A    current_time = datetime.datetime.utcnow()%0A%0A    if reference_name:%0A        note_filename = f'%7Breference_name%7D.md'%0A        note_path = get_git_root() / 'app' / 'reference' / note_filename%0A    else:%0A    
     
@@ -907,16 +907,20 @@
 %25M.md')%0A
+    
     note
@@ -1310,16 +1310,58 @@
 ain__':%0A
+    reference_name = get_reference_slug()%0A
     note
@@ -1382,16 +1382,30 @@
 te_note(
+reference_name
 )%0A    pr

Support generating references with newpost