summaryrefslogtreecommitdiff
path: root/note_tools/tomorrow.py
diff options
context:
space:
mode:
Diffstat (limited to 'note_tools/tomorrow.py')
-rw-r--r--note_tools/tomorrow.py24
1 files changed, 7 insertions, 17 deletions
diff --git a/note_tools/tomorrow.py b/note_tools/tomorrow.py
index 2198a3b..21b1fd5 100644
--- a/note_tools/tomorrow.py
+++ b/note_tools/tomorrow.py
@@ -3,25 +3,15 @@ import os
3from datetime import timedelta 3from datetime import timedelta
4import sublime 4import sublime
5import sublime_plugin 5import sublime_plugin
6from typing import Optional
6 7
7class NewNoteForTomorrowCommand(NoteBaseCommand, sublime_plugin.WindowCommand): 8class NewNoteForTomorrowCommand(NoteBaseCommand, sublime_plugin.WindowCommand):
8 def run(self): 9 def run(self):
9 self.date = self.get_date() + timedelta(days=1) 10 self.date += timedelta(days=1)
11 project_data = self.window.project_data()
10 12
11 notes_path = self.get_notes_path(self.window.project_data()) 13 def callback(success: bool, message: Optional[str], file_path: Optional[str]):
12 14 if not success:
13 if notes_path: 15 sublime.message_dialog(message)
14 year, month = self.get_date_parts()
15 directory = os.path.join(notes_path, year, month)
16 os.makedirs(directory, exist_ok=True)
17 file_path = os.path.join(directory, self.file_name())
18
19 # Check if file already exists
20 if os.path.exists(file_path):
21 sublime.message_dialog(f"The file '{self.file_name()}' already exists.")
22 else:
23 self.write_file_heading(file_path)
24
25 else:
26 sublime.message_dialog("No 'Notes' directory found in the project. Please add a 'Notes' folder.")
27 16
17 self.create_note(project_data=project_data, callback=callback)